統(tǒng)一彈登錄頁面,有的是在push出來的頁面彈登錄頁面,有的是在present頁面彈登錄頁面
說明 :
例如:A present B A就是presenting view controller(彈出VC); B就是presented view controller(被彈出VC);
解決方案:
//登錄
- (void)presentLoginVC
{
PhoneLoginViewController *loginVC = Storyboard(@"Main", @"PhoneLoginViewController");
UINavigationController *loginNav = [[UINavigationController alloc] initWithRootViewController:loginVC];
UIViewController *viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
/* viewController.presentedViewController只有present才有值,push的時候?yàn)閚il
*/
//防止重復(fù)彈
if ([viewController.presentedViewController isKindOfClass:[UINavigationController class]]) {
UINavigationController *navigation = (id)viewController.presentedViewController;
if ([navigation.topViewController isKindOfClass:[PhoneLoginViewController class]]) {
return;
}
}
if (viewController.presentedViewController) {
//要先dismiss結(jié)束后才能重新present否則會出現(xiàn)Warning: Attempt to present <UINavigationController: 0x7fdd22262800> on <UITabBarController: 0x7fdd21c33a60> whose view is not in the window hierarchy!就會present不出來登錄頁面
[viewController.presentedViewController dismissViewControllerAnimated:false completion:^{
[viewController presentViewController:loginNav animated:true completion:nil];
}];
}else {
[viewController presentViewController:loginNav animated:true completion: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調(diào)用了基類的設(shè)置高度的方法,在tableview沒有實(shí)現(xiàn)- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath這個代理方法,然后就會出現(xiàn)這個警告。