0

What UINavigationController event can be overridden to get access to current view controller?

My end goal is to check the current screen in the Navigation Controller to determine whether or not to call SetNavigationBarHidden.

Brian David Berman
  • 7,514
  • 26
  • 77
  • 144

2 Answers2

0

How about having a UINavigationController subclass adopt the UINavigationControllerDelegate protocol? Then implement the monotouch equivalent of navigationController:willShowViewController:animated: or navigationController:didShowViewController:animated:. Each of these methods passes a parameter which is a pointer to "[t]he view controller whose view and navigation item properties are being shown." You'll have to remember to make the navigation controller its own delegate.

0

If by "current" you mean "currently visible" you can make use of UINavigationController's VisibleViewController property. Though if you're using MT.D you'll want to cast it out:

var currentViewController = (DialogViewController)myNavController.VisibleViewController

Alternatively you could access the ViewController array directly. Or...you can also subclass DialogViewController and set the NavigationBar.Hidden = true inside the implementation.

Anuj
  • 3,134
  • 13
  • 17
  • I'm not seeing a property "NavigationBar" as part of DialogViewController. – Brian David Berman Dec 12 '11 at 06:33
  • Perhaps I should've been more prescriptive. But you can get access to the parent UINavigationController from inside an attached UIViewController. So it'd look like: this.NavigationController.NavigationBar.Hidden = true; – Anuj Dec 12 '11 at 06:42