@implementation UIWindow (****)
- (UIViewController*)df_currentViewController;
{
UIViewController *currentViewController = [self df_topMostController];
while ([currentViewController isKindOfClass:[UINavigationController class]] && [(UINavigationController*)currentViewController topViewController])
currentViewController = [(UINavigationController*)currentViewController topViewController];
return currentViewController;
}
- (UIViewController*)df_topMostController
{
UIViewController *topController = [self rootViewController];
// Getting topMost ViewController
while ([topController presentedViewController]) topController = [topController presentedViewController];
// Returning topMost ViewController
return topController;
}
@end
获取当前视图
最新推荐文章于 2023-06-12 15:19:20 发布