【问题标题】:Creating a Navigation View inside the standard Flipside view?在标准 Flipside 视图中创建导航视图?
【发布时间】:2009-08-19 20:52:11
【问题描述】:

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

【问题讨论】:

    标签: objective-c iphone uinavigationcontroller


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      您的应用程序委托头文件 (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];
      }
      

      【讨论】:

      • 似乎是一个非常好的解决方案!但是我在使它工作时遇到了麻烦。 rootViewController 是什么?我想它是根的视图控制器,但这不意味着它应该首先以某种方式实现吗?而且我在调用您使用[(MyAppDelegate *)[UIApplication sharedApplication].delegate showSettings] 描述的方法时遇到了麻烦。我尝试用 UIApplication.sharedApplication.delegate.showSettings 切换它,但仍然没有任何运气......希望你能提供帮助,因为这似乎是我最有可能采用的解决方案 - 如果我能让它工作的话。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 2022-06-16
      • 2014-09-27
      相关资源
      最近更新 更多