Reputation: 1678
I'm looking to understand the "best" way to transition to UITabBarController D (the main interface in my application) from either A or B - conditionally going through C.
Meaning I'd like all of the following to be valid.
A -> C -> D
A -> B -> C -> D
A -> B -> D
A -> D
C is a modal dialog which basically asks the user for a piece of missing information if they don't have it set in their profile.
I've tried:
Using a triggered modal segue from D -> C in the viewDidLoad function of D:
([self performSegueWithIdentifier:@"ShowNumberDialog" sender:self];)
Programatically displaying C as a modal on D in the viewDidLoad function:
(void)viewDidLoad
{
[super viewDidLoad];
NSString *deviceNumber = [[UserModel sharedSingleton] deviceNumber];
if ([deviceNumber isEqual:[NSNull null]]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"NumberDialog"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
NSLog(@"Showing device number dialog");
[self presentModalViewController:vc animated:NO];
}
}
Neither of these, plus uncountably other "hacky" attempts I've made seem to be working. So I assume I'm not understanding something fundamental about the way I'm supposed to do this. Can someone please recommend a better way?
Upvotes: 0
Views: 2831
Reputation: 257
Try moving the code you have in ViewDidLoad
to ViewDidAppear:(BOOL)animated
. What may be happening is that you are trying to push a modal dialog into the program while the transition to Tab Page D is still occurring which means the application disregards your request to open the modal dialog C as it continues to load D. ViewDidAppear:(BOOL)animated
is called when your view is finally visible to the user and fully loaded.
Upvotes: 1
Reputation: 359
So basically I don't understand the "performSegue..." from D to C. A TabBar is triggered by the user, so he has to tap the icon to come to this controller.
I would place C between B and D. Check if the informations are complete - if no --> Segue to C, otherwise to D.
Do you see problems in this approach?
Upvotes: 0