I have a login screen set up from the app delegate like this:
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;
}
In the view controller the start up methods are:
- (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];
}
The problems is that it seems to go in a infinite loop:
https://i.stack.imgur.com/fws6m.png
What is the problem? How do I fix it?
Yes, its obvous, you have recursive in your code. In each viewDidAppear you call another viewDidAppear.
Instead of:
call: