我从BaseViewController继承了我的ViewController,并且我使用storyboard ID推送了我的SecondViewController。但是,当我尝试从第二个视图查看控制器时它不起作用。这是我的代码:
dispatch_async(dispatch_get_main_queue(), ^{
[self showMesssgeonAlert:@"Success"];
[self hideProgress];
[self.navigationController popViewControllerAnimated:TRUE];
});
即使我尝试过:
NSArray *controllerArray = self.navigationController.viewControllers;
for (id controller in controllerArray)
{
if ([controller isKindOfClass:[ViewController class]])
{
[self.navigationController popViewControllerAnimated:TRUE];
}
}
但是,它在两种情况下都不起作用。我该怎么办?请帮助我。
确保你在ViewController上推动控制器SecondViewController,如果你正在使用segue,那么检查show类型(Push,Present Modally)。如果这是正确的,那么检查导航控制器对象,它应该有一个对象。
最后检查两个视图控制器中的导航控制器的内存地址是否加载方法。它应该是一样的。
你应该仔细检查:
尝试使用appDelegate导航控制器,尝试如下:
dispatch_async(dispatch_get_main_queue(), ^{
[self showMesssgeonAlert:@"Success"];
[self hideProgress];
[((AppDelegate*)[[UIApplication sharedApplication]delegate]).navigationController popViewControllerAnimated:TRUE];
});
拆分视图控制器可能会导致此问题,在我的情况下,我删除它,并且popViewController
开始工作。