views:

125

answers:

1

Hello, I have this code in my applicationDidFinishLaunching in the AppDelegate:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    NSString *firsttime = [defaults stringForKey:@"firsttime"];
    if (firsttime == nil) {

        BenutzerdatenViewController *Benutzer = [[BenutzerdatenViewController alloc] initWithNibName:nil bundle:nil];
        Benutzer.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [Benutzer release];

        [defaults setObject:@"lasttime" forKey:@"firsttime"];}
    else {  [window addSubview:viewController.view];
        [window makeKeyAndVisible];}

Always when I open the app the first time I just see a with "view" instead of the right view with buttons and so on. Where is the problem?

+1  A: 

You need to add the actual view to your window. For firsttime, you need the following:

[window addSubview: Benutzer.view];

Also, don't release that viewController; you should store a reference to it somewhere.

In the other case (!firstime), it's unclear where you're getting viewController from; I assume it's a member variable.

Ben Gottlieb
Thanks that helped :)
Flocked