Файл заголовка делегата приложения (MyAppDelegate.h):
@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
// We're assuming the root view for the main view is connected to this outlet of the app delegate
// It'll probably have a different class than UIViewController in your app
IBOutlet UIViewController *mainViewController;
UINavigationController *settingsNavigationController;
}
// Other view controllers can do [(MyAppDelegate *)[UIApplication sharedApplication].delegate showSettings] to show the settings
- (void)showSettings;
- (void)hideSettings;
@end
Файл вашего делегата приложения .m (MyAppDelegate.m):
- (void)showSettings
{
// Load the settings view controller the first time it's needed
// We're assuming you created the root view controller for the settings in a nib called SettingsRootViewController.xib. You might also just create the root view programmatically (maybe by subclassing UITableViewController)
if(settingsNavigationController == nil)
{
SettingsRootViewController *settingsRootViewController = [[[SettingsRootViewController alloc] initWithNibName:@"SettingsRootViewController" bundle:nil] autorelease];
settingsNavigationController = [[UINavigationController alloc] initWithRootViewController:settingsRootViewController];
settingsNavigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal
}
[rootViewController presentModalViewController:settingsNavigationController animated:YES];
}
- (void)hideSettings
{
[settingsNavigationController dismissModalViewController:YES];
}