标签:blog io ar div log window res c
UIWindow+PazLabs.h (header file)
#import <UIKit/UIKit.h> @interface UIWindow (PazLabs) - (UIViewController *) visibleViewController; @end
UIWindow+PazLabs.m (implementation file)
#import "UIWindow+PazLabs.h" @implementation UIWindow (PazLabs) - (UIViewController *)visibleViewController { UIViewController *rootViewController = self.rootViewController; return [UIWindow getVisibleViewControllerFrom:rootViewController]; } + (UIViewController *) getVisibleViewControllerFrom:(UIViewController *) vc { if ([vc isKindOfClass:[UINavigationController class]]) { return [UIWindow getVisibleViewControllerFrom:[((UINavigationController *) vc) visibleViewController]]; } else if ([vc isKindOfClass:[UITabBarController class]]) { return [UIWindow getVisibleViewControllerFrom:[((UITabBarController *) vc) selectedViewController]]; } else { if (vc.presentedViewController) { return [UIWindow getVisibleViewControllerFrom:vc.presentedViewController]; } else { return vc; } } } @end
得到当前活动的controller,布布扣,bubuko.com
标签:blog io ar div log window res c
原文地址:http://www.cnblogs.com/dokaygang128/p/3889745.html