I am having the following issue:
I have a UINavigationController with a UINavigationBar that changes title as you switch from one view to the next. For example, the first view could be called Root and the next view could be called Login. The first time (and the first time only) that I call [navigationController pushViewController:loginViewController animated:YES], the Login view comes in and the "Login" title appears on the nav bar only after the view has fully appeared. This is because I set the title in a function that is called from didShowViewController. What I would need to do is to call that same function from willShowViewController. The probl开发者_高级运维em is that the UINavigationItem for the new view controller has not been created yet so I cannot set the title... How do you get around that issue?
thanks,
franck-
You should be setting the title of the navigation item in the view controller's viewDidLoad
or loadView
method, rather than the UINavigationController
delegate methods. Setting the title
property of the view controller after creating it should also do the trick, however.
Just set the title property in the viewcontroller when you create it. The UINavigationItem is there already (or at least is created when you touch it), so there's no reason you can't set it then.
精彩评论