开发者

best way to build iphone settings screen

I'm building a settings screen for an iPhone app and it is supposed to resemble a grouped table view. Each "cell" should behave like a button. Most cells just have a image view, label view, and disclosure indicator. One will display a value in addition to a label. All of these buttons will present a new view when tapped.

Now, how to implement this? I was considering just laying out a set of buttons with custom background images, or would it be best to just use a table view. If that's the case what should it be implemented. So far I've only used table views to display some kind of dynamic data in which each cell displayed the same basic detail view. I'm most curious to figure out how to setup cel开发者_StackOverflow社区lForRowAtIndexPath. Would this contain some sort of switch statement to configure each cell individually, or is there an easier way to handle all this?


InAppSettingsKit is an open source project that recreates the settings app inside your app for UI consistency. You can pick it apart for your answers.


You'll want to use a UITableViewController with the sections set to be UITableViewStyleGrouped.

Each of the groups is a section, so you'll want to return how many sections you have with - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView.

For every section, you want to specify how many rows there are with - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section.

You'll want to customize each cell with - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath (which, by the way, tells you which section's particular row you're modifying in the indexPath variable).

Finally, you'll want to handle the row click in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath, using the pattern XCode provides for you:

[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];

Hope this helps!


Settings should go under the Settings 'App' on the iPhone. Your own App settings are incorporated into the standard Settings by adding a Settings.bundle to your own App.

It's straight-forward, and style-conformant.

How to do this is described here:

http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Preferences/Preferences.html%23//apple_ref/doc/uid/TP40007072-CH6-SW1


Firstly, if your application have settings which are not frequently modified you should prefer creating a settings bundle. but if you need to change the settings frequently from within you app like in a game, you should create settings screen by yourself.

Most of the cases the screen should match the settings default screen. For this you must make use of tableView with customized cells. You can make use of following controls inside the table cells depending on your settingtype. 1. alabel---for static text, 2. a switch --- for settings with two values(ON/OFF or o/1 or any two set of values) e.g. nightMode on/off, 3. a slider ---- for specifying range of values e.g brightness etc.

This you can configure in table view's cellForRowIndex delegate method on basis of the row index. You can also create sections to group similar types of settings under one type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜