I’d like to use a modal UITableView at startup to ask users for password, etc. if they are not already configured. However, the command to call the uitableview doesn’t seem to work inside viewDidLoad.
startup code:
- (void)viewDidLoad {
rootViewController = [[SettingsController alloc]
initWithStyle:UITableViewStyleGrouped];
navigationController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
// place where code doesn't work
//[self presentModalViewController:navigationController animated:YES];
}
However, the same code works fine when called later by a button:
- (IBAction)settingsPressed:(id)sender{
[self presentModalViewController:navigationController animated:YES];
}
Related question: how do I sense (at the upper level) when the UITableView has used the command to quit?
[self.parentViewController dismissModalViewControllerAnimated:YES];
You can place the
presentModalViewController:animated:call elsewhere in code – it should work in theviewWillAppearmethod of the view controller, or in theapplicationDidFinishLaunchingmethod in the app delegate (this is where I place my on-launch modal controllers).As for knowing when the view controller disappears, you can define a method on the parent view controller and override the implementation of
dismissModalViewControllerAnimatedon the child controller to call the method. Something like this: