在iPhone应用程序中安装设置视图

问题描述:

我正在iphone应用程序上工作。我想创建一个应用程序,该应用程序将具有一些设置视图,该视图仅在安装时显示,而不会在应用程序安装后显示。我怎么能这样做在iPhone应用程序中安装设置视图

你可以有东西出现时,应用程序是第一推出,但你不能在安装做任何事时间本身。你想在你的应用代理中这样做:

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    static NSString *firstLaunchKey = @"HasLaunchedBefore"; 

    if ([[NSUserDefaults standardUserDefaults] boolForKey:firstLaunchKey] == YES) { 
     // Launch your application as you normally do 
    } else { 
     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:firstLaunchKey]; 
     [[NSUserDefaults standardUserDefaults] synchronize]; 

     // Show your first-launch views here. 
    } 

    return YES; 
} 

你可以使用NSUserDefaults API来记录应用程序已经在设备上运行的事实。

在决定显示哪些意见,使用这样的检查:

if ([[NSUserDefaults standardDefaults] boolForKey:@"hasAppLaunchedBefore"]) 
{ 
    // this isn't the first time the app has run 
    // show normal views 
} 
else 
{ 
    // this is the first time the app has run 
    // show first-time views 

    [[NSUserDefaults standardDefaults] setBool:YES forKey:@"hasAppLaunchedBefore"]; 
}