ios - 仅在用户第一次打开应用程序时加载 View Controller

标签 ios cocoa-touch

这个问题在这里已经有了答案:





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/

相关文章:

ios - 与 Firebase 一起创建 DataManger

ios - 访问当前 View 的父 View - iOS

ios - 如何创建一个我可以在代码中的任何位置操作和访问的变量?

iOS AudioServicesPlayAlertSound 耳机静音

objective-c - 为什么标准循环失败时快速枚举有效?

ios - maskToBounds 与 ClipsToBounds

ios - 将应用程序提交到苹果商店时出现问题 - "This bundle is invalid"

iphone - 无法从 NSURLConnection 响应中解析 JSON 数据

ios - 不关闭 AlertController 的 UIAlertController 上的操作? (禁用解雇)

objective-c - 谷歌应用样式帮助查看