Search code examples
iphoneobjective-cioscocoauiwindow

iOS App window is not getting initialised


So, after spending the last week carefully designing and planning out my app, a request has come in to change it slightly. In order to make this change, I have to have everything as part of a navigation controller so that I can change views (currently using subviews which won't work correctly).

I have modified my AppDelegate.h and AppDelegate.m to have references to new windows and views , however I just get a black screen on launch.

After using the debugger, I noticed that the window pointer is in AppDelegate is still pointing at memory address 0, after it should have been initialised to the window I connected it to using interface builder.

Clearly I am doing something completely wrong, and I have no idea where to go from here. I don't even know what information I should be providing. To be on the safe side here is my AppDelegate.h:

#import <UIKit/UIKit.h>
#import "InitialisationController.h"


@interface AppDelegate : NSObject <UIApplicationDelegate>

@property (strong, nonatomic) IBOutlet UIWindow *window;
@property (strong, nonatomic) IBOutlet UINavigationController *navigationController;
@property (strong, nonatomic) IBOutlet InitialisationController *initialisationController;

@end

and the didFinishLaunchingWithOptions method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self.window addSubview:navigationController.view];
    [self setInitialisationController:[[InitialisationController alloc] initWithNibName:@"InitialisationController" bundle:nil]]; 
    //self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

    //[self.navigationController pushViewController:initialisationController animated:YES];
    [self.navigationController.view addSubview:[[self initialisationController] view]]; 

    return YES;  
}

Does anyone have even the slightest idea?

Thanks!


Solution

  • - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        self.initialisationController = [[InitialisationController alloc] initWithNibName:@"InitialisationController" bundle:nil]];
        navigationController = [[UINavigationController alloc] initWithRootViewController:self.initialisationController];
        [self.window addSubview:[navigationController view]];
        [self.window makeKeyAndVisible];
        return YES;
    }
    

    I think this will helpful to you.