开发者

detect current active subview of a navigation controller

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) { }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜