统一弹登录页面,有的是在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这个代理方法,然后就会出现这个警告。