我从应用程序委托设置了一个登录屏幕,如下所示:
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
BOOL needsPassCheck = [def boolForKey:kHasPassword];
if (needsPassCheck) {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
VerifyPasswordViewController *passC = (VerifyPasswordViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"passCheck"];
passC.loginCheck = YES;
self.window.rootViewController = passC;
}
在视图控制器中,启动方法是:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
if (self.loginCheck) {
[self.topBar setHidden:YES];
self.enterPLabel.text = NSLocalizedString(@"Enter Password", @"Enter Password");
}else {
[self.topBar setHidden:NO];
self.enterPLabel.text = NSLocalizedString(@"Enter Old Password", @"Enter Old Password");
}
[self.continueButton setTitle:NSLocalizedString(@"Continue", @"Continue") forState:UIControlStateNormal];
}
-(void)viewDidAppear:(BOOL)animated
{
[self.passwordTextField becomeFirstResponder];
[self viewDidAppear:animated];
}
问题是它似乎陷入了无限循环:http: //i.imgur.com/KmarG.png
问题是什么?我如何解决它?