开发者

Load an other View from applicationDidFinishLaunching in the AppDelegate

开发者 https://www.devze.com 2022-12-15 14:12 出处:网络
I have this code in my applicationDidFinishLaunching in the AppDelegate: - (void)applicationDidFinishLaunching:(UIApplication *)application {

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 *Benutze开发者_开发知识库r = [[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?


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.

0

精彩评论

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

关注公众号