我正在尝试调用控制器,如果有响应错误,则将用户重定向到登录控制器。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"EventManagerStoryboard" bundle:[NSBundle mainBundle]];
LoginViewController *loginController = [storyboard instantiateViewControllerWithIdentifier:@"loginID"];
[loginController viewDidLoad];
loginController.showOnlyLoginForm = YES;
[self presentViewController:loginController animated:YES completion:Nil];
我面对这个警告 -
尝试提示在ProfileController上显示LoginViewController:0x7fc958201130:0x7fc9583118e0,其视图不在窗口层次结构中!
答案 0 :(得分:1)
不要在viewDidLoad中运行此代码在viewDidAppear中尝试
[self presentViewController:loginController animated:YES completion:Nil];
编辑:
如果您实现navigationController
,请在appDelegate中使用 [(UINavigationController *)self.window.rootViewController pushViewController:vc animated:YES];