AppDelegate 中跳轉任意界面

- (UIViewController*)topViewController {    return [self topViewControllerWithRootViewController:self.window.rootViewController]; } - (UIViewController*)topViewControllerWithRootViewController:(UIViewController*)rootViewController {    if ([rootViewController isKindOfClass:[UITabBarController class]]) {        UITabBarController *tabBarController = (UITabBarController *)rootViewController;        return [self topViewControllerWithRootViewController:tabBarController.selectedViewController];    } else if ([rootViewController isKindOfClass:[UINavigationController class]]) {        UINavigationController* navigationController = (UINavigationController*)rootViewController;        return [self topViewControllerWithRootViewController:navigationController.visibleViewController];    } else if (rootViewController.presentedViewController) {        UIViewController* presentedViewController = rootViewController.presentedViewController;        return [self topViewControllerWithRootViewController:presentedViewController];    } else {        return rootViewController;    } }
相關文章
相關標籤/搜索