未显示iPhone navigationController

时间:2010-09-22 09:24:33

标签: iphone objective-c uinavigationcontroller pushviewcontroller

我的导航视图有一种非常奇怪的行为。我想要的是,从我的主视图来看,用户可以触摸一个按钮,通过应用程序设置将其引导到视图。

以下是负责导航的代码:

AppDelegate.h

    @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;
}

viewController.h

#import 
#import "optionsViewController.h" // the 'settings' view controller
@class AppDelegate;

@interface ViewController : UIViewController {
    AppDelegate *appDelegate;

viewController.m

- (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。如您所见,我将optionsController的负载从模态更改为导航。可能是,我错过了什么吗?

感谢您提前提示。

干杯,勒内

1 个答案:

答案 0 :(得分:1)

您是否已将其连接到Interface Builder中,如果不是在将其添加为子视图之前需要分配/初始化它?