在我的应用程序中添加一个设置页面(Xcode 和 Swift)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38231517/
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-15 09:01:00  来源:igfitidea点击:

Adding a settings page inside my app (Xcode and Swift)

iosxcodeswiftsettings

提问by Ludvig S?rensen

I want to add a settings page within my app. I have seen that there is a way to have a settings page (settings bundle) inside the native Settings app (like here: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html). But I want to have the settings for my app, within my app.

我想在我的应用程序中添加一个设置页面。我已经看到有一种方法可以在本机设置应用程序中设置设置页面(设置包)(例如:https: //developer.apple.com/library/ios/documentation/Cocoa/Conceptual/UserDefaults/Preferences/首选项.html)。但我想在我的应用程序中为我的应用程序设置设置。

I could do a couple of things, but I don't know which is the right approach... I could use the InAppSettingsKit (http://www.inappsettingskit.com/) or do everything manually which would be very messy(I think?) What have you guys/girls done with your settings in the past, and what do you think would be the best approach to this? And is there a better approach to this problem, than what I have listed above?

我可以做几件事,但我不知道哪种方法是正确的......我可以使用 InAppSettingsKit ( http://www.inappsettingskit.com/) 或手动完成所有事情,这会非常混乱(我想想?)你们过去对自己的设置做了什么,你认为最好的方法是什么?有没有比我上面列出的更好的方法来解决这个问题?

Thanks so much :)

非常感谢 :)

回答by AnthoPak

Depending the number of parameters you need in your settings, the approach could be different.

根据设置中需要的参数数量,方法可能会有所不同。

  • If you have a lot of parameters, with the need of rows containing sliders, switches or whatever advanced cell configuration, then using a library such as InAppSettingsKitis a good bet.

  • On the other hand, if you have only a few parameters, using UITableViewControllerwith Static Cellsand Grouped Stylecould be sufficient. You can do a lot of things in Interface Builderand perform actions in code.

  • 如果您有很多参数,并且需要包含滑块、开关或任何高级单元配置的行,那么使用诸如InAppSettingsKit 之类的库是一个不错的选择。

  • 另一方面,如果您只有几个参数,使用UITableViewControllerwithStatic CellsGrouped Style可能就足够了。您可以Interface Builder在代码中做很多事情并执行操作。

Choose the approach you're most comfortable with, I think both are respectable.

选择你最喜欢的方法,我认为两者都是值得尊敬的。