需要帮助创建复杂的 UITableView 项目(例如“设置”应用程序)

发布于 2024-07-29 19:03:32 字数 618 浏览 2 评论 0原文

我希望创建一个自定义设置视图,类似于“设置”应用程序,但可以更好地控制 UI 并访问某些设置(我需要锁定某些设置)。

显然,应用程序的 UITableView 的每一行中都混合了多种 UI 元素。 例如,“飞行模式”设置显示 UISwitch,而“Wi-Fi”设置则在显示符号 (“>”) 旁边有一个文本值。 使问题更加复杂的是这些设置的分组。

我对应该采取的方法有一些一般性问题:

  • 似乎我需要保存设置的名称、当前值、分组以及修改其值所需的 UI 元素的类型。 我想使用 [NSUserDefault standardUserDefaults],但这些设置没有出现在“设置”应用程序中。 我猜我需要创建自己的设置持久性类。

  • 在代码中构建这些复杂的 UI 元素组合中的每一个更好,还是基于 UITableViewCell 创建一系列自定义视图并加载适当的视图更好? 我猜是后者。

  • 某些设置要求我加载另一个视图来选择其值。 假设应用程序基于实用程序模式,SettingsView 是否应该管理导航堆栈,而不是让应用程序委托这样做?

感谢您的时间和评论。

克雷格·布坎南

I hoping to create a custom Settings view, similar to the Settings application, but with more control over the UI and access to some settings (i need to lock some of the settings).

Obvously, there are a variety of UI elements mixed in each row of application's UITableView. For example, the 'Airplane Mode' setting shows a UISwitch, while the 'Wi-Fi' setting has a text value adjacent to the disclosure symbol ('>'). Further complicating matters, is the grouping of these settings.

I have some general questions about the approach I should take:

  • Seems like i need to save the name of the setting, its current value, its grouping, and the type of UI element(s) needed to modify its value. i would like to make use [NSUserDefault standardUserDefaults], but not have these settings appear in the Settings application. I'm guessing that I will need to create my own settings-persistence class.

  • is it better to build each one of these complex UI-element combinations in code or to create a series of custom views based on the UITableViewCell and load the appropriate one? i'm guessing the latter.

  • some of the setting require that i load another view to select its value. assuming that the application is based on the Utility pattern, should the SettingsView manage the navigation stack, rather than having the app delegate do so?

Thanks for your time and comments.

Craig Buchanan

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

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

发布评论

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

评论(2

余生共白头 2024-08-05 19:03:32

如果您只是想在应用程序中显示 Settings.bundle,我建议您查看 InAppSettingsKit http ://www.inappsettingskit.com/ 或者您至少可以使用该框架作为起点。

至于您的一般问题,这是我的看法:

  • 性,我建议使用 NSPropertyListSerialization 或 NSDictionary 的 writeToFile:atomically: 将您的设置的 NSDictionary 简单地保存到应用程序文档文件夹中的 plist 文件中:

  • 我建议构建一系列自定义 nib,并在加载视图后对其进行缓存

  • 一定要让您的“设置”视图管理导航堆栈,这样您的设置视图就可以轻松地在其他项目中重用。

If you're just looking at displaying your Settings.bundle in your app, I suggest you take a look at the InAppSettingsKit at http://www.inappsettingskit.com/ Or you could at least use the framework as a starting point.

As for your general questions, here's my take:

  • For persistence, I would recommend simply persisting an NSDictionary of your settings to a plist file in your App's Document folder either using NSPropertyListSerialization or NSDictionary's writeToFile:atomically:

  • I suggest building a series of custom nibs and caching the views once they are loaded

  • Definitely have your Settings view manage the Navigation stack, that way your settings view can be reused in other projects easily.

徒留西风 2024-08-05 19:03:32

这是另一个“应用程序内设置”开源项目:
mySettings 只是另一个选项。 ..

Here is another "in app settings" open source project:
mySettings just another option...

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