2

I have app with UICollectionViews in UIPageViewController based on this tutorial for UIPageViewController, now I've embedded main view controller in navigation controller, and I want to change title of nav bar dynamically when in detail view, but how can I access it?

At first I've tried to embed in navigation controller Page View Controller, but nav bar wasn't displayed.

storyboard

edit: I've found out, that I can add navigation item to Time Snap Detail View Controller and set its title here, even though it's not visible in storyboard.

But how can I edit title in navigation bar, when I'm in Page View Controller?(In this case, on stack of the navigation controller is Main View Controller, which has Page View Controller as child view controller).

Adam Bardon
  • 3,829
  • 7
  • 38
  • 73

3 Answers3

1

I tried this, and it's ok:

childVC.parentViewController.navigationItem.title = @"abc";
Windle
  • 1,385
  • 2
  • 14
  • 33
Johny Li
  • 11
  • 1
1

The parent in view controller is not working anymore. Looks like the only way is to save the parent in this child view controller's method and set it's title:

override func didMove(toParent: UIViewController?)
juissi
  • 91
  • 6
0

try this. it's working for me in almost same scenario

    self.navigationController.parentViewController.navigationItem.title = @"sdfsdf.";
KennyVB
  • 745
  • 2
  • 9
  • 28