2

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 Answer 1

1

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

3
  • 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
    Sep 22, 2010 at 12:47
  • 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
    Sep 22, 2010 at 14:11
  • 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
    Sep 22, 2010 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.