You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 17, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 17, 2018. It is now read-only.
Default page not working properly when lazy loading three pages? #339
Expected behavior and actual behavior
I expect that when using defaultPage that the corresponding page always loads first without the interference of neighbouring pages (on either left or right side). The current behaviour (when loading page index 2 of 3) is that the fourth page (with index 3) is first loaded and then it jumps back to the page with index 2; it should always stay on index 2.
Steps to reproduce the problem
Create a PagingMenuController with four pagingControllers that loads some data into their views, then set defaultPage=2. If you see that the menu item which corresponds to the fourth page is shown before the menu item of the third page, you have reproduced it.
Specifications like the version of the project, library, or Swift
PagingMenuController version 2.2 and Swift version 3.0.2
EDIT: I use the following PagingMenuControllerCustomizable properties:
var componentType: ComponentType {
return .all(menuOptions: MenuOptions(menuItems: menuItems,
infinite: false, width: 180.0, widthMode: .flexible),
pagingControllers: pagingControllers)
}
var lazyLoadingPage: LazyLoadingPage {
return .three
}
var defaultPage: Int {
return 2
}
I have tried to "hack" some custom solution for it, but I always seem to end up very briefly showing the fourth page.
I managed to work around this by adding a protocol for hiding the pagingControllers until the defaultPage controller was done loading and being shown on screen. This (partly) works, but I still have to wait briefly before the defaultPage controller is being shown at all, leaving me with this void for a short duration. I want the behaviour to equal the behaviour I get when lazyLoadingPage=.one, only that I can swipe sideways as soon as my left and/or right "pagingControllers" are done loading.
This seemed to be a life cycle issue. Calling the setup of the PagingMenuController instance below super's viewDidLoad rather than super's viewWillAppear fixed this issue.
@kitasuke I have the same issue and am also using four view controllers, except I left the defaultPage var at 1. @thomaaam's fix didn't work for me.
The problem is the PagingMenuController always shows the last view controller first, however, the text that's displayed, underlined in the center of the menu is the defaultPage's menu title , but the view controller that's actually shown is the fourth view controller.
When I swipe to the right during this inconsistency, the menu item changes to the fourth view controller's title, but the view controller itself doesn't move at all, so afterwards, the fourth view controller is shown with its menu title, and it continues to work properly after that.
But if I instead swipe to the left, then the opposite happens, the view controller changes to the first view controller, and the menu item doesn't change at all, so afterwards, the first view controller is shown with its menu title, and it continues to work properly after that.
@kitasuke I'm also finding that no matter what I set the defaultPage to, when the PagingMenuController loads, the current menu item title correctly displays the defaultPage's title, but the view controller that's shown with it is always the view controller that's to the left of the defaultPage. The PagingMenuController always begins working properly after a single swipe is made to either the left or the right.
class PagingViewController: UIViewController {
internal func positionMenuController() {
if let currentViewController = currentViewController, let currentView = currentViewController.view {
contentScrollView.contentOffset.x = currentView.frame.minX
}
}
}
The frame of the currentViewController is all zeroes. How I'm creating the PagingMenuController is through interface builder. I have a view controller with a corresponding .xib file, I add the PagingMenuController to the view controller's .xib file, create an outlet for the PagingMenuController in the view controller's swift file, and link the PagingMenuController to it.
Doesn't matter whether I setup the PagingMenuController in my controller's viewDidLoad, viewWillAppear, or viewDidAppear, the issue persists.
Activity
thomaaam commentedon Mar 8, 2017
I managed to work around this by adding a protocol for hiding the
pagingControllersuntil thedefaultPagecontroller was done loading and being shown on screen. This (partly) works, but I still have to wait briefly before thedefaultPagecontroller is being shown at all, leaving me with this void for a short duration. I want the behaviour to equal the behaviour I get whenlazyLoadingPage=.one, only that I can swipe sideways as soon as my left and/or right "pagingControllers" are done loading.thomaaam commentedon Mar 10, 2017
This seemed to be a life cycle issue. Calling the setup of the
PagingMenuControllerinstance below super'sviewDidLoadrather than super'sviewWillAppearfixed this issue.biajoeknee commentedon Jul 17, 2017
@kitasuke I have the same issue and am also using four view controllers, except I left the
defaultPagevar at1. @thomaaam's fix didn't work for me.The problem is the
PagingMenuControlleralways shows the last view controller first, however, the text that's displayed, underlined in the center of the menu is thedefaultPage'smenu title , but the view controller that's actually shown is the fourth view controller.When I swipe to the right during this inconsistency, the menu item changes to the fourth view controller's title, but the view controller itself doesn't move at all, so afterwards, the fourth view controller is shown with its menu title, and it continues to work properly after that.
But if I instead swipe to the left, then the opposite happens, the view controller changes to the first view controller, and the menu item doesn't change at all, so afterwards, the first view controller is shown with its menu title, and it continues to work properly after that.
biajoeknee commentedon Jul 17, 2017
@kitasuke I'm also finding that no matter what I set the
defaultPageto, when thePagingMenuControllerloads, the current menu item title correctly displays thedefaultPage'stitle, but the view controller that's shown with it is always the view controller that's to the left of thedefaultPage. ThePagingMenuControlleralways begins working properly after a single swipe is made to either the left or the right.biajoeknee commentedon Jul 17, 2017
I'm finding the issue is in this method:
The frame of the
currentViewControlleris all zeroes. How I'm creating thePagingMenuControlleris through interface builder. I have a view controller with a corresponding.xibfile, I add thePagingMenuControllerto the view controller's.xibfile, create an outlet for thePagingMenuControllerin the view controller's swift file, and link thePagingMenuControllerto it.Doesn't matter whether I setup the
PagingMenuControllerin my controller'sviewDidLoad,viewWillAppear, orviewDidAppear, the issue persists.