xcode 为应用程序 ios 创建设置视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8875411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:00:29  来源:igfitidea点击:

Creating a settings view for app ios

objective-ciosxcode

提问by Teddy13

I would like to create a settings view within my app that so many apps today have implemented. In the past, I have created a settings bundle which the users can modify there settings for my app by going into system settings.

我想在我的应用程序中创建一个设置视图,今天有很多应用程序已经实现了。过去,我创建了一个设置包,用户可以通过进入系统设置来修改我的应用程序的设置。

My question is can I implement the .plist settings from the settings bundle into an ordinary view within my app? And if so, how is this done?

我的问题是我可以将设置包中的 .plist 设置实现到我的应用程序中的普通视图中吗?如果是这样,这是如何完成的?

Thank you in advance

先感谢您

回答by X Slash

http://www.inappsettingskit.com/does what you want. The example that comes with the source code will be great resources to look at.

http://www.inappsettingskit.com/做你想做的事。源代码附带的示例将是很好的资源。

回答by LJ Wilson

The two major options you got are:

您得到的两个主要选项是:

  1. Create a PList within your project and assign key/value pairs and then create a ViewController that includes UISwitches, TextBoxes, Sliders, etc and then just use these controls to integrate with that PList.
  2. If you are talking less than 4-5 settings, use NSUserDefaults to store/read the values of these settings. You will still need to create a ViewController for the UI, but won't need a PList.
  1. 在您的项目中创建一个 PList 并分配键/值对,然后创建一个包含 UISwitches、TextBoxes、Sliders 等的 ViewController,然后只需使用这些控件与该 PList 集成。
  2. 如果您谈论的设置少于 4-5 个,请使用 NSUserDefaults 来存储/读取这些设置的值。您仍然需要为 UI 创建一个 ViewController,但不需要 PList。

I personally like having settings within the app for most cases. Legal statements, copyright notices and settings that won't be touched but once are probably better off using the SettingsBundle, but for settings that are updated or changed often should reside inside the app in my opinion.

我个人喜欢在大多数情况下在应用程序中进行设置。法律声明、版权声明和设置不会被触及,但使用 SettingsBundle 可能会更好,但对于经常更新或更改的设置,我认为应该驻留在应用程序中。

回答by slonkar

I guess NSUserDefaults would be gr8 option if you not saving large amount of data.

如果您不保存大量数据,我想 NSUserDefaults 将是 gr8 选项。