ios 8.2及更高版本的设置捆绑包未显示所选项目,但默认 [英] ios 8.2 and above settings bundle is not showing selected item but Default
问题描述
我遇到了应用程序设置问题,我正在使用设置捆绑包选择环境,但是一旦选择并返回到应用程序设置,它会再次显示默认设置.
I am facing a issue with App settings, i am using settings bundle to select the environment, but once selected and going back to app settings its showing again the default one as selected.
仅在ios 8.2及更高版本(设备和模拟器)中观察到此情况. 我的设置捆绑包plist如下所示.
This is observed only from ios 8.2 and above(Device and simulator). My settings bundle plist looks like below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>DefaultValue</key>
<string>1</string>
<key>Key</key>
<string>Environment</string>
<key>Title</key>
<string>Environment</string>
<key>Titles</key>
<array>
<string>Live</string>
<string>Stage</string>
</array>
<key>Type</key>
<string>PSRadioGroupSpecifier</string>
<key>Values</key>
<array>
<string>0</string>
<string>1</string>
</array>
</dict>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
我已经在Stack溢出中看到一些信息,这是Apple的现有错误,我希望有人对它进行任何更新.
I already see some info in Stack overflow that this is existing bug from Apple, I hope if some one has any any update on it.
推荐答案
如果在启动过程中设置了外观设置,则必须重新加载应用程序的视图控制器以显示更改,以便可以将类似的内容添加到您的应用程序中:
If your apperance settings are set during launch, you must reload your app viewcontrollers to display the change, so you could add to your appDelegate something like:
NSString *type
在您的代码中
然后
type = [[NSUserDefaults standardUserDefault] objectForKey:@"Your key"];
在您的didFinishLaunchingWithOptions:
方法中
最后,在您的didEnterForeground
方法中,添加
and finally, in your didEnterForeground
method, add
if(![[[NSUserDefaults standardUserDefault] objectForKey:@"Your key"] isEqualToString:type]){
//Reload your main view controller
[self.window.rootViewController viewDidLoad];
[self.window.rootViewController viewWillAppear:YES];
}
这篇关于ios 8.2及更高版本的设置捆绑包未显示所选项目,但默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!