Hello,
I'm building a nib-less iOS app utilizing a UINavigationController. I do not want the home screen to show the NavigationBar, but on the sub pages I do want to show the NavigationBar.
My hope was to use the ViewDidAppear event to show/hide the NavigationBar as I push and pop UIViewControllers to the UINavigationController. However, ViewDidAppear does not appear to be firing for my UIViewControllers.
Here is my AppDelegate.cs:
Window = new UIWindow (UIScreen.MainScreen.Bounds);
UINavigationController rootNavController = new UINavigationController ();
rootNavController.PushViewController (new Home (), false);
Window.RootViewController = rootNavController;
Window.BackgroundColor = UIColor.Black;
Window.MakeKeyAndVisible ();
And here is my Home UIViewController:
public partial class Home : UIViewController
{
#region Constructors
public Home () : base()
{
}
#endregion
#region ViewController Events
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// I setup UI elements here but removed for brevity.
}
public override void ViewDidAppear (bool animated)
{
base.ViewDidAppear (animated);
this.NavigationController.SetNavigationBarHidden (true, false);
}
#endregion
}
The button TouchUpInside method I use to get to the next UIViewController is this:
btnFindCourses.TouchUpInside += (object sender, EventArgs e) => {
this.NavigationController.PushViewController(new FindCourses(), true);
};
Flow-wise everything works fine (i.e. the UIViewController FindCourses loads up and I see the UI elements that I add in the ViewDidLoad event (where I am also showing the NavigationBar). So on first load of the app, no NavigationBar on the home page and then the NavigationBar appears on the sub page (great!).
The trouble is, when I tap the Back button in the NavigationBar to go back to the Home UIViewController the NavigationBar is visible, even though I have the code above in the Home ViewController ViewDidAppear event which is supposed to hide the NavigationBar.
I've setup breakpoints in the ViewDidAppear method and it never hits. Any suggestions on what's going on? Let me know if I can provide any more code. I have also tried ViewWillAppear to no avail.
Thanks everyone!