iOS-關于側邊欄模態出VC出現的問題

今天在項目中碰到了一個小問題,點擊側邊欄的Button模態出一個VC,而這個VC恰好是根視圖的VC。運行的時候報了一個錯誤,記錄下來。。。

剛開始我是直接用self調用的presentViewController,出現了報錯,但是程序正常運行。。。

側邊欄模態問題.png

解決方法:

/**退出登錄*/
-(void)clickExitButton:(UIButton *)sender{
   ...
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        //跳轉到登錄界面
        LoginViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
         AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
        [delegate.window.rootViewController presentViewController:[[MyNavigationController alloc] initWithRootViewController:vc] animated:YES completion:nil];
    });
   ...
}

引申傳送門,查了度娘才看到這個答案。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容