Warning: Attempt to present错误
来源:互联网 发布:37周胎儿发育标准数据 编辑:程序博客网 时间:2024/05/29 03:24
获取当前的controller
- (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;
}
- (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;
}
}
转自:http://www.cocoachina.com/bbs/read.php?tid=295517
1 0
- Warning: Attempt to present错误
- Warning: Attempt to present <NextViewController: 0x10966fed0> on
- 使用AlertController出现:Warning: Attempt to present <UIAlertController: 0x7a961600>
- iOS: Warning: Attempt to present <ModalViewController> on <ViewController>while a presentation is in
- 对Warning: Attempt to present on whose view is not in the window hierarchy!的解决方案
- Warning: Attempt to present A on B whose view is not in the window hierarchy!
- 对Warning: Attempt to present on whose view is not in the window hierarchy!的解决方案
- 对Warning: Attempt to present on whose view is not in the window hierarchy!的解决方案
- Warning: Attempt to present * on * whose view is not in the window hierarchy!
- Warning: Attempt to present xx on yy whose view is not in the window hierarchy!
- Warning: Attempt to present A on B whose view is not in the window hierarchy!
- Warning: Attempt to present A on B whose view is not in the window hierarchy!
- Warning: Attempt to present UINavigationController on NavigationController which is already presenti
- 对Warning: Attempt to present on whose view is not in the window hierarchy!的解决方案
- Warning: Attempt to present ControllerA and ControllerB whose view is not in the window hierarchy!
- Warning: Attempt to present <UIImagePickerController: 0x292b400> on xxx which is already presenti
- Warning: Attempt to present <...> on <…> which is already presenting null
- iOS - 解决Warning: Attempt to present <UIImagePickerController: 0x7f9ba106a000>which is already presen
- [2016/06/29] LeetCode / Java - Day 07 -
- 下拉刷新上拉加载代码
- SVN基本操作
- Leetcode 110. Balanced Binary Tree
- 棒棒剁两刀
- Warning: Attempt to present错误
- java如何给单片机串口发送一个16进制的命令
- windbg下查看应用层ntdll!NtOpenProcess
- OkHttp使用详解——完全版
- JavaScript 高级知识
- 朴素贝叶斯实例——邮件分类
- 校长和英语老师一起去法国某中学访问,校长在礼堂讲话,英语老师做翻译
- Xml解析pull
- 获取input标签后的文本及<input />,<input>和<input></input>区别