Three20通过openURLAction进行导航; self.navigationController 在推送的 VC 中为零?

发布于 2024-09-18 20:44:13 字数 722 浏览 7 评论 0原文

导航从一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

束缚m 2024-09-25 20:44:13

这是 viewDidLoad 是错误位置的事情之一 - 在比较各种视图控制器并发现它们的调用方式没有真正的区别之后(但有 nil viewControllers虽然其他人没有)但我突然意识到,如果它真的为零,那么 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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文