设计应用程序设置的表格视图的最佳做法? [英] Best practices for designing table view for app settings?

查看:116
本文介绍了设计应用程序设置的表格视图的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用程序的设置视图控制器,我希望有一个表视图,其中包含一组用户可以调整的选项。切换开关,segue,步进等等。

For my app's settings view controller, I want to have a table view with a bunch of options the user can tweak. Toggle switches, segues, steppers, etc.

实现这一目标的最佳方法是什么?在每个单元遵循简单布局的情况下,表视图非常简单。也许是一个标题和一些潜台词。但是在这种情况下,单元格可能是五种布局中的一种,具体取决于要更改的设置类型。

What's the best way to accomplish this? Table views are quite simple in the case where each cell follows a simple layout. Maybe a title and some subtext. But in this case a cell may be one of, say, five layouts depending on what kind of setting is being changed.

处理此类的最佳方法是将UITableViewCell子类化,并在tableView的 cellForRowAtIndexPath:中,在您将单元格设置为 kind 之类的自定义属性之前,将其设置为切换标签?然后在该单元格子类的 viewDidLoad 中根据种类属性设置单元格?

Is the best way to handle this to subclass UITableViewCell, and in the tableView's cellForRowAtIndexPath:, before you return the cell set a custom property like kind to something like toggle or label? Then in the viewDidLoad of that cell subclass set the cell up based on the kind property?

效率低吗?我应该创建一个包含所有控件但已隐藏的单元格,然后根据 kind 启用它们吗?我是否应该为每种具有不同控件的单元格创建一个子类?

Is this inefficient? Should I make a cell with all controls already on it, but hidden, then just enable them based on kind? Should I have a subclass for each kind of cell with different controls that I want?

这就是我在考虑处理它的方式。但是有更优选的方式吗?这种效率是否低效,因为它不具有从一个单元到另一个单元的必然可预测模式?

That's how I'm thinking about handling it. But is there a more preferred way? Is this inefficient because it doesn't have a necessarily predictable pattern from cell to cell?

推荐答案

我不喜欢这个想法我必须调试其他人的代码,如果我不喜欢它的东西。这就是为什么我尝试自己编写代码,然后看看它是否符合我的需求。如果没有,那么我会去看看InAppSettingsKit。

I don't like the idea that I have to debug someone else's code if incase i didn't like something in it. That's why I try to write code on my own and then see if it fits my needs or not. If it doesn't then I would go and take a look at InAppSettingsKit.

你所要求的是一个非常简单的东西,我已经实现了我的几乎每个应用程序,即带有选项的UITableView。

What you have asked for is a very simple stuff and I have implemented in almost every app of mine i.e. UITableView with options.

这就是我要做的。您可以在xcode中直接完成所有这些操作。

this is how I would do it. You can do all this straight up in xcode.


  • 创建UITableView控制器

  • 制作一个导航控制器。因此您可以在其上添加标题,例如单词settings

  • 将其更改为静态单元格

  • 然后将其更改为分组的单元格

  • 根据需要创建任意数量的组

  • 根据需要为每个单元格添加开关

  • 为每个单元添加页脚和标题分组

  • 根据需要在每个选项旁边添加漂亮的图片。

  • Create a UITableView Controller
  • Make it a navigation controller. So that you can add heading on it like with word "settings"
  • Change it to static cells
  • Then change it to grouped cells
  • Create as many groups as you need
  • For each cell add switches as needed
  • Add footer and header to each grouping
  • Add pretty pictures next to each option as you like.

我希望这会有所帮助。这是我的示例项目设置截图之一。你看不到我创建的页眉和页脚。

I hope this helps. Here is one of my sample project settings screenshot. You cannot see header and footer that I had created.

这篇关于设计应用程序设置的表格视图的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆