0

I have a paged, horizontal PageViewController used for a swipe-based interface. In one of these views is a Navigation Controller which segues to a second detail view.

When the second view appears I would like to hide the parent view's Navigation Bar but I don't know how to access any method on the parent view.

I imagine it would look something like this in the detail view

-(void)viewWillAppear {
    [parentViewClassNameHere setNavigationBarHidden:YES];
}

How would one go about setting up an accessible method on the parent?

Gabriel M Sharp
  • 335
  • 1
  • 6
  • 17

1 Answers1

0

The Navigation Bar is actually owned by the UINavigationController where both the parent view controller and your second view controller are pushed on. So if you hide the navigation bar from your second view controller, it means you are also hiding the bar from the parent view controller.

You can hide the navigation bar with

[[secondDetailViewController navigationController] setNavigationBarHidden:YES animated:YES];

If you still want to have an accessible method on the parent, see this post for different ways to have an instance to the parent view controller. Then you can call any public method on the instance.

Community
  • 1
  • 1
Antenehs
  • 336
  • 1
  • 7
  • That code isn't working as it stands. How would I pass an instance through prepareForSegue? – Gabriel M Sharp Nov 08 '14 at 19:13
  • I have updated the answer and put a link to a good post that shows how to send data to the parent. You can use the same method for calling a method as well. – Antenehs Nov 08 '14 at 22:11