解決Warning: Attempt to present <UINavigationController: 0x7fdd22262800> on <UITabBarController: 0x7fdd21c33a60> whose view is not in the window hierarchy!問題

統(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)這個警告。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 統(tǒng)一彈登錄頁面,有的是在push出來的頁面彈登錄頁面,有的是在present頁面彈登錄頁面 說明 : 例如:A p...
    左岸花不開閱讀 1,456評論 0 1
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,321評論 4 61
  • 2017.02.22 可以練習(xí),每當(dāng)這個時候,腦袋就犯困,我這腦袋真是神奇呀,一說讓你做事情,你就犯困,你可不要太...
    Carden閱讀 1,490評論 0 1
  • 1. “媽,晚安!”凌晨一點(diǎn),亦舒發(fā)出了一條信息。每晚發(fā)出這樣一條信息時她都會心痛好一陣。“兒子,昨晚又工作那么晚...
    gl菲菲閱讀 814評論 18 15
  • 事實(shí)上,平衡只是無稽之談,它是一個遙不可及的夢想……我們想探求工作與生活之間的平衡,這番追求不僅無法實(shí)現(xiàn),而且會帶...
    一米霞光閱讀 445評論 0 0

友情鏈接更多精彩內(nèi)容