我有一个 iOS 应用程序,它的根目录有一个 UITabBarController(它有三个选项卡)。
在 viewDidAppear 的第一个选项卡中:如果用户尚未注册,我将提供以下内容来显示 RegisterViewController:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
RegisterViewController *registerViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"RegisterView"];
[registerViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:registerViewController animated:NO completion:nil];
当用户点击 RegisterViewController 中的“注册”按钮时,它会在收到 HTTP 响应后显示 QuestionnaireViewController。
当点击 QuestionnaireViewController 中的“提交”按钮时,我可以通过以下方式关闭它:
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
然后我发布一个 RegisterViewController 正在监听的通知:
[[NSNotificationCenter defaultCenter] postNotificationName:UserHasCompletedQuestionnaireNotification object:nil];
现在,这就是我的问题所在 - 当 RegisterViewController 听到通知时,我尝试将其关闭,但不能。
我尝试了各种不予理会的含义,例如:
[[self tabBarController] dismissViewControllerAnimated:YES completion:nil];
什么都不做,并且:
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
这给出了以下错误:
attempt to dismiss modal view controller whose view does not currently appear. self = <RegisterViewController: 0x8525ea0> modalViewController = <UINavigationController: 0x74545e0>
attempt to dismiss modal view controller whose view does not currently appear. self = <UITabBarController: 0x8320060> modalViewController = <RegisterViewController: 0x8525ea0>
希望有人能够告诉我我在这里做错了愚蠢的事情。
谢谢,尼克