Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contentViewController won't scroll to specific page programmatically #108

Open
helloC1ndy opened this issue Dec 17, 2019 · 1 comment
Open

Comments

@helloC1ndy
Copy link

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

  1. 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.

  1. 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.)

@helloC1ndy helloC1ndy changed the title contentViewController won't scroll to specific page successfully programmatically contentViewController won't scroll to specific page programmatically Dec 17, 2019
@kazuhiro4949
Copy link
Owner

Thanks for your question. I'll check the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants