Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices for designing table view for app settings?

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.

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?

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?

like image 210
Doug Smith Avatar asked Jul 05 '13 18:07

Doug Smith


2 Answers

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.

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.

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

  • 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.

enter image description here

like image 126
Sam B Avatar answered Sep 16 '22 18:09

Sam B


Since you're using this for settings, have you considered InAppSettingsKit?

In cases where that may be overkill, I have resorted to creating a static tableview in a storyboard where I can layout each distinct setting and have design-time control over its appearance.

like image 21
Wayne Hartman Avatar answered Sep 19 '22 18:09

Wayne Hartman