1

有谁知道如何在标准翻转视图中创建导航视图以读取和更新设置?如果是这样,您能否发布一些有关执行此操作的代码。

4

2 回答 2

0

您的应用程序委托头文件 (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];
}
于 2009-12-10T02:32:01.807 回答
0

您可以将反面视图设为 UINavigationController 的子类。

或者,如果您只需要导航栏,而不需要推送/弹出新的视图控制器并且从 NIB 加载翻转视图,那么只需在 NIB 文件中添加导航栏。

于 2009-11-25T09:01:34.933 回答