views:

47

answers:

1

Hi all 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é

+1  A: 

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

jodm
To clarify what I am saying if you connect a "UINavigationController" in Interface Builder you do not need to alloc/init. But if you are hand coding it you need to alloc/init it before you [window addSubview:]
jodm
I suppose what you mean is the code
renesteg
I suppose what you mean is the code <pre> [[optionsViewController alloc] initWithNibName:@"optionsViewController" bundle:nil];</pre> ? Yes I alloc / init and even give it the nib name.
renesteg
Still not showing then?
jodm
No it is still not showing up. I have set breakpoints in the optionsViewController and it does not get even to the DidLoad method. As you said I guess there is still a missing link somewhere....
renesteg