i have a navigation controlle开发者_开发技巧r. i want to runa background thread on that controller which checks which subview is loaded currently in the navigation controller. loaded means tha active viewable subview.
You don't have to (or should) use a background thread for this. Simply set the navigation controller's delegate and implement the method
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
You can then store the currently active view controller in an instance variable.
there is a UINavigationController
property for that (from here):
topViewController
The view controller at the top of the navigation stack. (read-only)
@property(nonatomic, readonly, retain) UIViewController *topViewController
simply do:
UIViewController* topController = navigationController.topViewController;
for (UIView *view in self.navigationController.view.subviews)
{
}
for (UINavigationController *view in self.view.subviews) { }
精彩评论