NavigationController 不推送视图
我正在从应用程序委托访问导航控制器并尝试推送另一个视图:
[appDelegate.myNavigationController pushViewController:self.detailView animated:YES];
但什么也没有发生。上面是myTableView中的。
该应用程序是基于标签栏的。我在IB中的TabbarController对象下添加了一个NavigationController对象。然后我在应用程序委托中创建了对 myNavigationController 的引用。
有什么建议我可以找出为什么上面的代码不起作用吗?如果 addSubview 到当前视图,它会起作用。
I'm accessing a navigation controller from the app delegate and trying to push another view:
[appDelegate.myNavigationController pushViewController:self.detailView animated:YES];
but nothing is happening. The above is in myTableView.
The app is tabbar based. I added a NavigationController object under the TabbarController object in IB. Then I created a reference to myNavigationController in the app delegate.
Any suggestions how I can figure out why the above code isn't working? It works if addSubview to the current view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保
appDelegate
不为 null(无论您从何处获取它都会返回正确的值),appDelegate.myNavigationController
不为 null(IBOutlet 设置正确),并且appDelegate.myNavigationController.window
不为 null(它当前显示在堆栈顶部。还要确保在推送新项目之前,之前推送或弹出视图的所有动画都已完成) 。
Make sure that
appDelegate
is not null (wherever you're getting it from is returning the right value),appDelegate.myNavigationController
is not null (the IBOutlet was setup properly), and thatappDelegate.myNavigationController.window
is not null (it is currently displayed on the top of the stack.Also make sure that any animations of previous pushing or popping of views are complete before you push your new item.
这可能无法回答您的问题。
你的代码看起来很混乱。该代码片段是来自
UITableView
子类还是来自UITableViewController
子类?让我问的是,您的pushViewController:
参数是self.detailView
。保持清晰的区别极其重要。如果从显示导航栏的视图控制器调用代码,那么您应该使用 self.navigationController 而不是向 appDelegate 添加属性。
特别是,您需要在选项卡中使用导航控制器。
其中任何一个都可能导致视图不显示的问题。
This may not be an answer to your question.
Your code looks confusing. Is the snippet from a
UITableView
subclass or from aUITableViewController
subclass? What makes me ask is that your argument forpushViewController:
isself.detailView
. Keeping the distinction clear is extremely important.If the code is being called from a view controller that shows a navigation bar, then you should be using
self.navigationController
rather than adding a property toappDelegate
.In particular, you need to be using the navigation controller in your tab.
Any of these could cause a problem with the view not appearing.