-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Hi, thank you for sharing this great project with everyone! I really like it! But I have a little issue here hoping someone could help me. Thanks a lot!!
About The Issue
I want to add my pages dynamically, reload both menu & content, and then scroll the menu & content to the last page. It turns out menuViewController works successfully, but contentViewController just can't scroll to the last page. Not sure why.
My Tries & Results
- reload first, scroll later
func addNewPage() {
let vc = self.storyboard!.instantiateViewController(withIdentifier: "myViewController")
pageList.append(vc)
let lastPageIndex = pageList.endIndex
menuViewController.reloadData()
contentViewController.reloadData()
menuViewController.scroll(index: lastPageIndex)
contentViewController.scroll(to: lastPageIndex, animated: true)
}
Result: menuViewController will scroll to the last index, but contentViewController always stays at first index.
- use reload-with-preferredFocusIndex function
func addNewPage() {
let vc = self.storyboard!.instantiateViewController(withIdentifier: "myViewController")
pageList.append(vc)
let lastPageIndex = pageList.endIndex
menuViewController.reloadData(with: lastPageIndex, completionHandler: nil)
contentViewController.reloadData(with: lastPageIndex, completion: nil)
}
Result: menuViewController will scroll to the last index, so does contentViewController. BUT, contentViewController is totally blank!! (It didn't load its input views. But when I do a little scroll, like try to scroll to previous page a little but not really scroll to there, then contentViewController will load its input view successfully.)