iphone - [[self tabBarController] navigationController] 和 self.navigationController 之间的区别
我有一个带有选项卡控制器的应用程序,对于一个选项卡,我使用导航控制器。
有人可以告诉我 [[self tabBarController] navigationController]
和 self.navigationController
之间有什么区别吗?
I have an app that has a tabbarcontroller and for one tab I use a navigationcontroller.
Can someone tell me what the difference between [[self tabBarController] navigationController]
and self.navigationController
is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
[[self tabBarController] navigationController]
将获取 tabBarController 所在的 navigationController。self.navigationController
获取self
所在的 navigationController。如果相应的实例不是navigationController堆栈的一部分(如果它们不在navigationController中),这些属性将返回
nil
[[self tabBarController] navigationController]
will get the navigationController that the tabBarController is inside.self.navigationController
gets the navigationController thatself
is inside.These properties will return
nil
if the respective instances are not part of a navigationController's stack (if they aren't in a navigationController)我认为
[[self tabBarController] navigationController]
是所选选项卡的当前导航控制器。而 self.navigationController 是当前类的导航控制器。I think that
[[self tabBarController] navigationController]
is the current navigation controller of the selected tab. Andself.navigationController
is the navigation controller of the current class.http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW44
导航控制器如果请求属性的控制器位于导航控制器的堆栈中,则属性返回导航控制器。
您的标签栏控制器不是标签栏导航控制器的一部分,在您的情况下应该为零。
http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW44
The navigationController property returns a navigation controller if the the controller the property is asked from is in the navigation controller's stack.
Your tab bar controller is not part of a navigation controller of the tab bar which should be nil in your case.