开发者

detect current active subview of a navigation controller

开发者 https://www.devze.com 2023-03-06 19:37 出处:网络
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

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

精彩评论

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

关注公众号