这个问题在这里已经有了答案:
Creating a first launch viewcontroller
(1 个回答)
8年前关闭。
我想向我的 iOS 应用程序添加一些代码,仅在用户第一次下载并打开应用程序时打开 View Controller - 之后它不应该加载此 View Controller 。任何其他时间,它应该在启动时打开到不同的 View Controller 。
最佳答案
在您的 AppDelgate
, didFinishLaunchingWithOptions
,分配您的self.viewController
作为启动屏幕。
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"yourCondition"])
{
//launch your first time view
self.viewController = [[ViewController alloc] initWithNibName:@"singletimeview" bundle:nil];
}
else
{
//launch your default view
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"yourCondition"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
关于ios - 仅在用户第一次打开应用程序时加载 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20723153/