在 AppDelegate 中从 applicationDidFinishLaunching 加载另一个视图 [英] Load an other View from applicationDidFinishLaunching in the AppDelegate

查看:23
本文介绍了在 AppDelegate 中从 applicationDidFinishLaunching 加载另一个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AppDelegate 的 applicationDidFinishLaunching 中有此代码:

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?

推荐答案

您需要将实际视图添加到您的窗口中.第一次,您需要以下内容:

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

[window addSubview: Benutzer.view];

另外,不要释放那个viewController;您应该在某处存储对它的引用.

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

在另一种情况下 (!firstime),不清楚您从哪里获得 viewController;我假设它是一个成员变量.

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

这篇关于在 AppDelegate 中从 applicationDidFinishLaunching 加载另一个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆