How should I present a Modal VIew Controller from TabBarController
I have an app whose initial scene is a tab bar controller with 3 tabs. I
created a uitabbarcontroller class and set it to that scene
(MainTabViewController).
In that class I call presentLogin from the viewDidAppear method and that
method reads:
- (void)presentLogin{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (![prefs stringForKey:@"storedUser"] && ![prefs
stringForKey:@"storedPass"]) {
NSLog(@"No user prefs stored");
// BUT WAIT, before all this, lets pop up a view controller for
user registration
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Storyboard"
bundle:nil];
ModalViewController *popupController = [sb
instantiateViewControllerWithIdentifier:@"ModalViewController"];
[self presentViewController:popupController animated:YES
completion:nil];
} else {
NSString *storedUser = [NSString
stringWithFormat:@"User:%@",[prefs stringForKey:@"storedUser"]];
NSString *storedPass = [NSString
stringWithFormat:@"User:%@",[prefs stringForKey:@"storedPass"]];
UIAlertView *internetAlert = [[UIAlertView alloc]
initWithTitle:storedUser
message:storedPass
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok",
nil];
[internetAlert show];
}
}
But the modalVC isnt showing for some reason. I get this crash log:
Attempting to begin a modal transition from to while a transition is
already in progress. Wait for viewDidAppear/viewDidDisappear to know the
current transition has completed
No comments:
Post a Comment