开发者

iPhone navigationController is not displayed

开发者 https://www.devze.com 2023-01-17 07:01 出处:网络
I have a very strange behaviour of my navigation view. What I want is, that from my main view, the user can touch a button, which leads him to the view with the application settings.

I have a very strange behaviour of my navigation view. What I want is, that from my main view, the user can touch a button, which leads him to the view with the application settings.

Here is the code, responsible for the navigation:

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];

}

My optionsController is a 'normal' UIViewController. As you see did I change the load of the optionsController from modal to navigation. Could it be, that I missed something here?

Thanks for any hints in advance.

Cheers, René


Have you connected it up in Interface Builder if not you need to alloc/init it before you add it as a subview?

0

精彩评论

暂无评论...
验证码 换一张
取 消