iOS判断控制器是push还是present的
2023-03-29 本文已影响0人
善良的karl
有时候一个页面有时候是需要push弹出,有时候是需要present模态弹出,返回的时候,就要用pop和dismiss的方式销毁,那么如何判断呢,解决方案如下:
-(void)cancelButtonClick {
if (self.presentingViewController) {
[self dismissViewControllerAnimated:YES completion:^{}];
}else{
[self.navigationController popToRootViewControllerAnimated:YES];
}
}