今天在項(xiàng)目中碰到了一個(gè)小問(wèn)題,點(diǎn)擊側(cè)邊欄的Button模態(tài)出一個(gè)VC,而這個(gè)VC恰好是根視圖的VC。運(yùn)行的時(shí)候報(bào)了一個(gè)錯(cuò)誤岖圈,記錄下來(lái)。钙皮。蜂科。
剛開(kāi)始我是直接用self調(diào)用的presentViewController,出現(xiàn)了報(bào)錯(cuò)短条,但是程序正常運(yùn)行导匣。。茸时。
側(cè)邊欄模態(tài)問(wèn)題.png
解決方法:
/**退出登錄*/
-(void)clickExitButton:(UIButton *)sender{
...
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//跳轉(zhuǎn)到登錄界面
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];
});
...
}
引申傳送門(mén)贡定,查了度娘才看到這個(gè)答案。