Ios7 NavigationController不会推送到完成块内部
我正在编写一段代码,当用户按下提交按钮时,他会被要求在进入应用程序屏幕之前更新密码。因此,当您按下按钮时,“登录”过程将被执行,用户将通过应用程序的身份验证,在完成块中,我们将显示“重置密码”视图控制器。然而,推动似乎不起作用。我确实在块之前和块内打印navigationController对象,它不是nilIos7 NavigationController不会推送到完成块内部,ios7,uinavigationcontroller,objective-c-blocks,Ios7,Uinavigationcontroller,Objective C Blocks,我正在编写一段代码,当用户按下提交按钮时,他会被要求在进入应用程序屏幕之前更新密码。因此,当您按下按钮时,“登录”过程将被执行,用户将通过应用程序的身份验证,在完成块中,我们将显示“重置密码”视图控制器。然而,推动似乎不起作用。我确实在块之前和块内打印navigationController对象,它不是nil NSLog(@"%@", [self.navigationController description]); __weak __typeof(self) weakSelf = self;
NSLog(@"%@", [self.navigationController description]);
__weak __typeof(self) weakSelf = self;
[[AppDelegate sharedDelegate] login:self.userIdentifierTextField.text
password:self.passwordTextField.text
persistence:NSURLCredentialPersistencePermanent
completion:^(BOOL success, NSError *error) {
SignInViewController *innerWeak = weakSelf;
if ([[Features sharedFeatures] allowsAdminMandatedPasswordReset]) {
//User needs to add new password
ResetPasswordViewController *resetViewController = [[ResetPasswordViewController alloc] initWithNibName:[ResetPasswordViewController nibName] bundle:nil];
NSLog(@"%@", [self.navigationController description]);
if (innerWeak.navigationController != nil) {
[innerWeak.navigationController pushViewController:resetViewController animated:YES];
}
}
[MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
mainWindow.userInteractionEnabled = YES;
}];
这里,当我比较navigationController对象上的两个NSLog时,它们是相同的。即使以模式呈现resetViewController也在完成块中工作,但推送不起作用。我花了很多时间试图弄清楚,我完全搞不清楚到底发生了什么
更新:使用以下工具对我很有用。但我仍然希望找到weakSelf.navigationController问题的根本原因
[[AppDelegate sharedDelegate].navigationController pushViewController:resetViewController animated:YES];
您正在主线程上执行完成块吗?是的。我在主线程上运行。我已经用块内的[NSThread isMainThread]对其进行了验证。