best way to build iphone settings screen - iphone

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

Related

iPhone UIViewController Lag

I have a 'detail' page where I am displaying info for a club. The page is a UIViewController and consists of buttons and labels to acheive this look (like small grouped tables). When I load this page on a device, it lags a bit, more than any other view in my app.
I assume its because I have quite a few objects on the view controller. Does anyone have any suggestions on how to reduce this lag? Or how to achieve the look the 3 smaller tables like this(grouped) in a different way?
Thanks.
SCREENSHOT:
You could try making custom tablecells and use UITableView instead?
You could just make the view a UITableView using UITableViewStyleGrouped style, and then programmatically create the cells for each row. Overriding
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
gets you your titles like "Meeting Information" and "Contact", and overriding
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
gets you correct sizing on each table cell. If the text in "General Information" is not going to be a constant size, you can use the
-sizeWithFont::(UIFont *)font
method of NSString in your heightForRowAtIndexPath implementation.
The issue is not likely your interface design. UI drawing is pretty snappy usually. The things that slow it down are accessing data. If you have a large data set you are searching you might look at ways to speed that up.

Implementing keyboard (inputView) with UITableViewCell

I am looking for the most direct way to make it so that when the user taps a UITableViewCell, a keyboard appears. I want to use a custom keyboard (UIPickerView) and I preferably would like to make the cell style UITableViewCellStyleValue2. I can't seem to find a very direct way of doing this. I have a navigation bar on top, and hoping to make the buttons on that change as well...
Thanks!
First and foremost, to achieve this you're going to have to handle the custom animation of the UIPickerView sliding up and down. They keyboard is handled automatically by the controls that automatically need it (UITextField, UITextView, etc.).
So when your view loads you will want to create and configure your picker and then move its Y coordinate to CGRectGetMaxY([[UIScreen mainScreen] applicationFrame]);
Then in your - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath you will call a method that is responsible for animating your picker view into place. The only problem I foresee with this approach is allowing the user to dismiss this picker view in a way that makes sense as users are used to input views sliding only when they're needed (meaning that they appear when a view becomesFirstResponder and they disappear automatically when that view resignsFirstResponder status).
I think I understand what you're trying to achieve here and I would do it a bit differently. Instead of displaying a picker with options when you select a cell I would instead push a new tableViewController with your options laid out as cells. Then when the user makes a selection, you can set a checkmark and pop back to the original view.

Appearance of table cells when deleting

I'm trying to make a table view with an appearance much like the default Weather application provided by Apple. However I'm struggling a bit to make the table cells look correctly.
I would like all the cells, except the first one to be deletable. The problem is that the default cells have the small delete button on the left side of the cell instead of inside the cell. This causes the cells to shrink to the right, except the first one which keeps its size since it's not deletable.
So my question is if there is any way to tweak the default UITableViewCell to have the same behavior as the cell used in the Weather app? Or do I have to implement my own cell with button animation, etc, etc?
It turned out that somebody else had already answered this in a slightly different question:
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
return NO;
}
it looks like that all apple is doing is making the background black for the delete button content area. i would try doing something like that first.

How to decrease width of table view cells for iphone

I'm trying to create a grouped table view with two sections. For the first section I would like the width to be only half the screen. For the second section it would be the standard width. Also, next to the first section I would like to put a button.
How is this done?
Thanks!
To put a button in a section what I've done in the past is create a section that has no rows in it. Then, I respond to the - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section method with a view that contains a button that is rigged to whatever delegate I need. This will give you the appearance of having a button sitting in a section with no data. This is how buttons appear in the Contacts view/edit screens in the stock iPhone apps.
Table view sections are fixed with to the size of the screen. If you want the individual cells to appear narrower in one section and wider in another, then you can control the size of the view itself with the data source delegate, though you might have to set the background of the table view to transparent so users can actually see the smaller view on top of the table view.

Look like iPhone inbuilt contact applications image selection

I have created an application in which i have to add users to the sqlite database.
Now the problem is I want the look of the standard iPhone Contact application Where while adding user we have the width of first cell smaller than other cells and the image before that cell..
Can you please give me the idea how such thing is possible.
How to make one cell small and rest others of normal size..
Thanks for any help in advance
There are three UITableViewDelegate messages you can listen for to adjust height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
However, even thought I didn't write Contacts.app I have a feeling they are also using
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
To adjust the views as well. Remember, you don't have to pack everything into a single monolithic custom table view cell. You can create multiple custom table view cells and load them each appropriately depending on the index path.
The contact detail view is a grouped tableview. Each cluster of cells is a section. The top section is a single custom cell with two subviews that look like squashed tableview cells. The left view shows the contact's photo. The right view shows the name.
To reproduce, create a custom UITableView subclass and lay it out like you want either programmatically or in Interface Builder. Then in the tableview delegate's cellForRowAtIndexPath check indexPath.section and return the proper row for the section.
It appears that the Contacts app uses a custom tableHeaderView when presenting the contact details with an image and label. A similar implementation is included in the sample project iPhoneCoreDataRecipes. The RecipeDetailView loads a separate nib in tableViewHeaderView that is used to set the tableView.tableHeaderView property. Have a look at RecipeDetailViewController.{h,m} and DetailHeaderView.xib. When the Contacts app switches to editing mode, the headerView appears to be swapped out for another view that has a button and a tableView with a single cell. This will allow you to set up a separate tableViewDelegate to handle the Name parts of the contact and a delegate to handle the address / telephony details.