简体   繁体   中英

iOS - Settings - Modal Segue to Table view controller

I would like to build a settings interface for the iOS app.

Note - These settings would often change so I prefer a setting interface app instead of the settings bundle

My thoughts

  • I liked the modal segue to get to the settings view
  • my settings view is going to be a table view
  • I prefer if the table view is static (as each cell might lead to a different view)

Problems:

  1. In modal view, the navigation bar doesn't seem to appear. I would need the navigation bar, so that I can create a "Save" button on it ?

  2. In order to solve the above mentioned, I created a UIViewController to manage the settings view and added a navigation bar and a table view under the UIViewController's view (Using a UITableViewController to cause the navigation bar to scroll with the cells)

  3. But creating a UIViewController doesn't allow me to create a table with static content

Questions:

  1. How can the above mentioned be achieved ?
  2. Is there a better way to do a settings screen ?
  3. Is it better to create dynamic content tables and have different cell identifiers for different types cells (eg cells with slider / cells with text box etc) ?

If you're using Storyboarding, this is a very easy thing to accomplish. Just add a new scene to your storyboard: 在此处输入图片说明

...then add a UIBarButtonItem to your main scene: 在此处输入图片说明

...then link the UIBarButtonItem to the scene you just added by using Control+Click to drag from the button to the scene. Choose a "modal" transition: 在此处输入图片说明

...then, in the new scene you've added, you can customize the table cells by using the right-hand side menu. If you choose "Custom" as the cell type, you can add switches, etc to the tableview. 在此处输入图片说明

From there, I'd recommend you take a look at hooking those switches up to methods, and then take a look at NSUserDefaults for how to store the settings and link them up to this viewController. Here's the documentation for NSUserDefaults .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM