Three20通过openURLAction进行导航; self.navigationController 在推送的 VC 中为零?
导航从一个 UIviewController 控制器的 [[TTNavigator navigator] openURLAction:theUrl];
开始,另一个 UIViewController 是该 URL 的目标。地图是使用以下代码设置的,毫无疑问导航会到达正确的位置:
TTURLMap* map = navigator.URLMap;
[map from:@"tt://goToMyViewController" toViewController:[MyViewControllerClass class]];
在推送的视图控制器中,我想操作“后退”按钮上的图像,但不想更改标题。它应该始终是被推到其顶部的视图控制器的标题,如果没有设置标题,则应本地化为“返回”。
问题: 在此推送的视图控制器的 viewDidLoad 中,我首先
NSArray* viewControllers = self.navigationController.viewControllers;
获取导航堆栈,以便可以查看相应视图控制器的标题。但 viewControllers 为零...
但是,如果我什么都不做,默认后退按钮确实具有正确的标题。我想查看 leftBarButtonItem 和 backBarButtonItem 标题属性,但那里也没有任何意义...
任何人都知道发生了什么事,为什么会发生这种情况或如何解决?
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 starting 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是
viewDidLoad
是错误位置的事情之一 - 在比较各种视图控制器并发现它们的调用方式没有真正的区别之后(但有 nilviewControllers
虽然其他人没有)但我突然意识到,如果它真的为零,那么 popViewControllerAnimated 也不应该工作。我发现viewControllers
在我调用popViewControllerAnimated
的地方不为零,并且从那里实验表明我可以在viewWillAppear:
中获得我想要的标题。因此,viewWillAppear: 似乎是触摸 self.navigationController 的可靠位置,而 viewDidLoad 则不然。
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 nilviewControllers
while others didn't) it struck me that if it was really nil,popViewControllerAnimated
shouldn't work either. I foundviewControllers
was NOT nil where I was callingpopViewControllerAnimated
and from there experiment showed I could get the title I was after inviewWillAppear:
.So,
viewWillAppear:
seems to be a reliable place to touchself.navigationController
whileviewDidLoad
is not.