简体   繁体   中英

iphone - Difference between [[self tabBarController] navigationController] and 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?

[[self tabBarController] navigationController] will get the navigationController that the tabBarController is inside.

self.navigationController gets the navigationController that self 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)

I think that [[self tabBarController] navigationController] is the current navigation controller of the selected tab. And self.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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM