uias / Pageboy

📖 A simple, highly informative page view controller
MIT License
1.99k stars 155 forks source link

Unable to change Child view controllers navigation title when view controller swapped. #119

Closed vinodiOS closed 7 years ago

vinodiOS commented 7 years ago

I want to change title of child controllers when they scrolled or navigated using barItemButtons.

msaps commented 7 years ago

@vinodiOS you can do this pretty easily by utilising the PageboyViewControllerDelegate. When a page is scrolled to, you can use the currentViewController property to access the visible child view controller and update the parent navigation title.

Something like this:

func pageboyViewController(_ pageboyViewController: PageboyViewController,
                               didScrollToPageAt index: Int,
                               direction: PageboyViewController.NavigationDirection,
                               animated: Bool) {
     let childTitle = pageboyViewController.currentViewController?.title
     pageboyViewController.navigationItem.title = childTitle
}
vinodiOS commented 7 years ago

Thank you @msaps