obtaining UINavigationController in an UIView
a custom tab bar controller I am using applies the ViewController or UINavigationController like this: UIViewController* viewController = [data objectForKey:@"viewController"];
I dont knw exactly how it works but "viewController" comes out as a UINavigationController. Next, the custom tab bar controller class adds a tag like so, viewController.view.tag = THE_TAG;
Retrieving the controller is uses UIView* currentView = [self.window viewWithTag:SELECTED_VIEW_CONTROLLER_TAG];
This part is where I get confused because now when I nslog this "currentView" I get a UILayout etc... instead of my UINavigationController. I'm assuming it applied the tag to the UIView that contained the nav controller?
How do I reference the UINavigationContr开发者_StackOverflow中文版oller within this UIView?
In the above what is THE_TAG
, and can you confirm that it is unique (i.e. not zero, and not matching something being used elsewhere by the same mechanism)?
I'd be pretty wary overusing tag
since there is no easy way to gaurentee globally unique tags, and when using something like self.window viewWithTag
you could see just about every view in the app being checked.
It seems like you have a view and a viewController confused. A UINavigationController is a subclass of UIViewController. It is not a subclass of UIView. UIViewControllers do have a property which is a UIView class. It is probably this property that you are accessing when you use viewWithTag: . So maybe, when you use that method, you are not accessing the UINavigationController but the UINavigationController's view property (which is actually something you should probably not be messing with.)
精彩评论