Attempt to present <UINavigationController: 0x14694de00> on <HomeViewController: 0x14658fef0> whose view is not in the window hierarchy!

统一弹登录页面,有的是在push出来的页面弹登录页面,有的是在present页面弹登录页面

说明 :

例如:A present B

A就是presenting view controller(弹出VC);

B就是presented view controller(被弹出VC);

解决方案:

//登录- (void)presentLoginVC{  

PhoneLoginViewController *loginVC = Storyboard(@"Main",@"PhoneLoginViewController");UINavigationController*loginNav = [[UINavigationControlleralloc] initWithRootViewController:loginVC];UIViewController*viewController = [UIApplicationsharedApplication].keyWindow.rootViewController;/* viewController.presentedViewController只有present才有值,push的时候为nil

*///防止重复弹

if([viewController.presentedViewControllerisKindOfClass:[UINavigationControllerclass]]) {

UINavigationController*navigation = (id)viewController.presentedViewController;if([navigation.topViewControllerisKindOfClass:[PhoneLoginViewController class]]) {return;        }    }

if(viewController.presentedViewController) {//要先dismiss结束后才能重新present否则会出现Warning: Attempt to present on whose view is not in the window hierarchy!就会present不出来登录页面[viewController.presentedViewControllerdismissViewControllerAnimated:falsecompletion:^{            [viewController presentViewController:loginNav animated:truecompletion:nil];        }];    }else{        [viewController presentViewController:loginNav animated:truecompletion:nil];    }}

2.Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.

这个是自定义cell调用了基类的设置高度的方法,在tableview没有实现- (CGFloat)tableView:(UITableView)tableView heightForRowAtIndexPath:(NSIndexPath)indexPath这个代理方法,然后就会出现这个警告。


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容