如何获得我的应用程序的“首次打开"视图? [英] How to get a "first time open"-view for my app?

查看:71
本文介绍了如何获得我的应用程序的“首次打开"视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第一次启动应用程序时,我试图找到一种方法使我的程序显示设置"视图,但是它无法正常工作.

I'm trying to find a way that my program will show up a "setup"-view, when you first start the app, but it doens´t works.

这是我的尝试.如果程序是第一次打开(abfrage = false)并打开另一个视图,则appdelegate应该会看到.

Here is my attempt. The appdelegate should look, if the program opens the first time (abfrage = false) and open an other view.

#import "TweetButtonAppDelegate.h"
#import "TweetButtonViewController.h"
#import "BenutzerdatenViewController.h"

@implementation TweetButtonAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize abfrage;


- (void)applicationDidFinishLaunching:(UIApplication *)application {
    abfrage = FALSE;
if (abfrage == TRUE) {
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
} else {
    BenutzerdatenViewController *Benutzerdaten = [[BenutzerdatenViewController alloc] initWithNibName:nil bundle:nil];
    [Benutzerdaten release];}
}
(...)

我试图在appdelegate中构建一个if-query,但是总是在"abfrage"为false的情况下,程序才加载一个白色视图.

I tried to build a if-query in the appdelegate, but always when "abfrage" is false, the program just loads a white view.

推荐答案

我有一个解决方案,可以在AppDelegate的applicationDidFinishLaunching中进行设置:

I got a solution, which can be set in the applicationDidFinishLaunching of the AppDelegate:

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

        TheOtherViewController *Other = [[TheOtherViewController alloc] initWithNibName:nil bundle:nil];
        Other.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [window addSubview: Other.view];        

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

这篇关于如何获得我的应用程序的“首次打开"视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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