方法1 取出当前的导航控制器
// 取出当前的导航控制器
UITabBarController *tabBarVc = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
UINavigationController *nav = (UINavigationController *)tabBarVc.selectedViewController;
[nav pushViewController:web animated:YES];
方法2
XMGPostWordViewController *postWord = [[XMGPostWordViewController alloc] init];
XMGNavigationController *nav = [[XMGNavigationController alloc] initWithRootViewController:postWord];
// 这里不能使用self来弹出其他控制器, 因为self执行了dismiss操作
UIViewController *root = [UIApplication sharedApplication].keyWindow.rootViewController;
[root presentViewController:nav animated:YES completion:nil];
方法3
- (UIViewController *)ViewController
{
UIResponder *next = [self nextResponder];
do {
if ([next isKindOfClass:[UIViewController class]]) {
return (UIViewController *)next;
}
next = [next nextResponder];
} while (next != nil);
return nil;
}
网友评论