如何将设置包中的首选项说明符之一默认为 YES?

发布于 2024-09-16 20:39:22 字数 410 浏览 2 评论 0原文

当我在iPhone上测试时,我遇到了一个奇怪的问题...我有一个settings.bundle,其中有一个用于background_sounds的布尔值,默认情况下设置为YES。问题是,当应用程序第一次加载时,background_sounds pref 在检查时似乎设置为 NO。我尝试过同步 NSUserDefaults 和所有内容,但使其检测background_sounds 设置的唯一方法是转到应用程序的“设置”页面,不要触摸任何内容,然后返回到app...然后声音再次开始正常播放。

有什么想法吗?设置包中有错误还是只有我这样?谢谢!

编辑:如果我以正确的方式使用 NSUserDefaults ,我实际上可以让它从设置包中读取首选项。只是我必须先物理打开 iPhone 上的设置面板,然后才能在应用程序中注意到它们。没有任何意义...

I've got a weird one when I test on the iPhone... I have a settings.bundle that has a Boolean for background_sounds which is set to YES by default. The problem is, when the app loads first time, the background_sounds pref seems to be set to NO when checked. I've tried synchronizing NSUserDefaults and everything, but the only way of making it detect the background_sounds setting, is to go to the Settings page for the app, don't touch anything and then go back to the app... Then the sounds start playing again fine.

Any ideas? Is there a bug in the settings bundle or is it just me?? Thanks!

EDIT: I can acatually get it to read the preferences from the settings bundle, if I use NSUserDefaults in the correct way. It's just that I have to physically OPEN the settings panel on the iPhone FIRST before they are noticed in the app. Makes no sense...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-09-23 20:39:22
[[NSUserDefaults standardUserDefaults] registerDefaults:<dictionary>];

您是否正在注册您的偏好值?

[[NSUserDefaults standardUserDefaults] registerDefaults:<dictionary>];

Are you registering your preferences value?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文