gpt4 book ai didi

iPhone didFinishLaunchingWithOptions 方法

转载 作者:行者123 更新时间:2023-12-03 20:46:37 27 4
gpt4 key购买 nike

所以我尝试使用此方法根据用户在设置包中选择的内容加载特定主题。当我插入 NSLog 时,它将加载默认的它们(现代主题),但它永远不会更改为粉红色主题。

每次启动应用程序时都会加载此方法,即使应用程序仍在后台运行。

否则,如果我想使用设置包,我还能在哪里执行此操作。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary *userDefaultsDefaults = [NSDictionary dictionaryWithObjectsAndKeys: @"Modern Theme", @"theme", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsDefaults];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
theme =[defaults objectForKey:@"theme"];

NSLog(@"%@", theme);

if ([theme isEqualToString:@"Modern Theme"]) {
viewController = [[viewTwo alloc] initWithNibName:@"viewTwo" bundle:nil];
}
else {
viewController = [[viewOne alloc] initWithNibName:@"viewOne" bundle:nil];
}

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

return YES;
}

最佳答案

您是否尝试过将代码放入 applicationDidBecomeActive: 中?无论是在首次启动还是从后台恢复时,都保证会调用该函数。

Reference docs

关于iPhone didFinishLaunchingWithOptions 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5643373/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com