How to create a iPhone Settings-like view
I want to create a view similar to the iPhone's Settings app.
I开发者_JS百科s this view using a UITableView or what? Are the items created programmatically or is it possible to do this in Interface Builder?
It is a UITableView with style: UITableViewStyleGrouped
It is possible to do so in Interface builder and there are a number of ways.
This article describes the most intuitive way a Google search has to offer: http://www.galloway.me.uk/tutorials/custom-uitableviewcell/
Key steps are:
- Create UIViewController with xib (not table view controller)
- replace it's initial view with a UITableView
- implement UITableViewDelegate and UITableViewDatasource protocols
- add any additional UITableViewCells to Interface Builder as extra views
- refer to them in your view controller class as IBOutlet UITableViewCell *
- use connections inspector to connect IBOutlets in view controller to cells in Interface Builder
Have a look at InAppSettingsKit Project which does not only to do settings in your app but it also provides the ability to have the settings externalized into the iPhone's settings app. This is probably the easiest way to get settings into your app.
What you see in the Settigs App is different sections of a UITableView
with "grouped" style, using a navigation controller. Have a look at the UICatalog example, as well as the Table View Programming Guide for iOS.
Try FormKit. It will let you create Settings app like forms very easily.
精彩评论