开发者

Three20 navigation by openURLAction; self.navigationController is nil in pushed VC?

The navigation commences with [[TTNavigator navigator] openURLAction:theUrl]; from one UIviewController controller and another UIViewController is the target of that URL. The map is set with set with the following code and there is no doubt navigation goes to the right place:

TTURLMap* map = navigator.URLMap;
[map from:@"tt://goToMyViewController" toViewController:[MyViewControllerClass class]];

In the pushed view controller i want to manipulate the image on the Back button but don't want to change the title. It should always be the title of the view controller this one was pushed on top of, or localized "Back" if no title was set.

Problem: In this pushed view controller's viewDidLoad I'm start开发者_如何学Cing with

NSArray* viewControllers = self.navigationController.viewControllers;

to get the navigation stack so I can look at the title of the appropriate view controller. But viewControllers is nil...

However if I do nothing the default back button does have the correct title. I thought of looking at the leftBarButtonItem and backBarButtonItem title properties but there is nothing meaningful there either...

Anyone know what is going on, why this is happening or how it can be worked around?


This is one of those things where viewDidLoad is the wrong place to do it - after comparing various view controllers and finding no real difference in how they were invoked (yet had nil viewControllers while others didn't) it struck me that if it was really nil, popViewControllerAnimated shouldn't work either. I found viewControllers was NOT nil where I was calling popViewControllerAnimated and from there experiment showed I could get the title I was after in viewWillAppear:. So, viewWillAppear: seems to be a reliable place to touch self.navigationController while viewDidLoad is not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜