代码之家  ›  专栏  ›  技术社区  ›  renesteg

未显示iPhone navigationController

  •  0
  • renesteg  · 技术社区  · 15 年前

    我的导航视图有一个非常奇怪的行为。我想要的是,在我的主视图中,用户可以点击一个按钮,这将引导他进入带有应用程序设置的视图。

    下面是负责导航的代码:

        @interface AppDelegate : NSObject  {
        UIWindow *window;
        ViewController *viewController; // My Main View Controller
        UINavigationController *navigationController; } 
    
        @property (nonatomic, retain) IBOutlet UIWindow *window;
        @property (nonatomic, retain) IBOutlet ViewController *viewController;
        @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
    

    AppDelegate.m公司

    @synthesize viewController;
    @synthesize window;
    @synthesize navigationController;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
        [window addSubview:viewController.view];
        [window addSubview:navigationController.view];
        [window makeKeyAndVisible];
        return YES;
    }
    

    视图控制器.h

    #import 
    #import "optionsViewController.h" // the 'settings' view controller
    
    @class AppDelegate;
    
    @interface ViewController : UIViewController {
        AppDelegate *appDelegate;
    

    - (IBAction)showOptionsViewController:(UIBarButtonItem *)sender {
    //  optionsController.theSubjectID = self.theSubjectID;
    //  [self presentModalViewController:self.optionsController animated:YES];
    
    
        optionsViewController *optionsController= [[optionsViewController alloc] initWithNibName:@"optionsViewController" bundle:nil];
        optionsController.theSubjectID = self.theSubjectID;
        [self.navigationController pushViewController:optionsController animated:YES];
        [optionsController release];
    
    }
    

    我的optionsController是“普通”UIViewController。如您所见,我将选项控制器的负载从模式更改为导航。是不是我错过了什么?

    干杯,任

    1 回复  |  直到 15 年前
        1
  •  1
  •   jodm    15 年前

    你是否在interfacebuilder中连接了它,如果没有的话,你需要在把它添加为子视图之前分配/初始化它?