multiple column menu in iPhone - iphone

I want to create a menu like below for my iPhone app. Is it possible?
First, only the main items will display. and when we clicking on a main item its sub items will show in two columns.

The easiest way to do it is using a customized UITableView with sections.
Each header of each section will correspond to your "Main Item X". You can use a custom view for your headers thanks to the UITableViewDelegate methods, so you can provide a UIView containing a UILabel and the image of your ">" or "v", and a UITapGestureRecognizer to handle the tap that will open of close the submenus
Each section will contain either 0 (if the menu is closed) or N items (if it is open)
Each cell of your tableView, that will correspond to a row, will contain two labels (or buttons), one for the item on the left and one for the item on the right.
When the UITagGestureRecognizer of a section is tapped, you can toggle a BOOL that tells if the section is "open" or "closed" and then call reloadData on your UITableView to show or hide the corresponding cells
The rest is basic table view programming so you can implement the table view as you usually do (see the "Table View Programming Guide" in the Apple doc for more details).

Related

About UITableView Component

I'm new to developing applications for iphone and am studying alone.
I'm trying to make a view equal to the link below:
https://docs.google.com/open?id=0B26lA9znN3CUY3BBeW00NGo0RDA
I would REALLY make a view like this, with the switch button, the labels between the cells of the UITableView.
This example is used more than a UITableView? Or are several separate?
I could not find any examples like this. If there is a similar example would release it for download?
To replicate this view, create a table view controller with a 'grouped' style for the table - there's only one table. The table uses standard iOS views and styles (e.g., sections, footers, accessory views).
Section one:
Cell one: custom cell style w/ a UILabel # left and a UISwitch # right
Cell two: right detail cell style (UILabel # left and right) and disclosure indicator accessory
Section footer: return a UILabel w/ the text for section one by implementing the table view delegate method 'tableView:viewForFooterInSection'.
Section two:
Cell one: basic cell style (UILabel # left) and disclosure indicator accessory
Section three:
Cell one: right detail cell style (UILabel # left and right)
With the exception of the section one footer, all of this can be easily implemented in a storyboard.
The view you are looking at is not a normal UITableView, it is the Settings page of Skype.
Therefore you have to have a look at Settings.bundle. Here is a link to Apples Website that is describing it. Here is a good tutorial that describes how to set up a Settings page.
Update: There is an open source project available that lets you include the settings page directly in your application, as you wished:
http://www.cocoacontrols.com/platforms/ios/controls/inappsettingskit
I believe the free Sensible TableView framework enables you to achieve this using a very few number of lines.

UItableView custom cell with a plus button on the left side (outside table view)

I want to add a plus button outside my table view cell (on the left side), but the button should get scrolled if I am scrolling the table. Does anyone has a solution for this??? Also, there are 8 different sections in my table. There is no need to show that plus button for the first 7 sections, but there is a plus button in the 8th section clicking on which will increase the number of sections by 1. (the catch here is that the plus button is NOT INSIDE THE CELL and there are different sections where we will not show the plus button, so no UNIFORMITY).
I belive that the best solution to this is to create a custom section header (or footer) view and put the button there. It will "look" like it's outside the table, but it will be inside the given view.
In your case, only inside the section header/footer of section 7.
That button will scrool along with the table, as the section header/footer will.
Or, alternatively, you could have an "empty" section 8 (with no rows, but with a header) and display the button there. If you want the button displayed, you should return the number of section as "8", if you want the button hidden, return section count as "7".

How to use first responder to keep only one cell selected at the maximum in a view with multiple table views?

I have a scrollview which has several table views as sub views...
say that I have selected a cell in one of the sub views. Now when I select a cell from another view, the cell I selected previously should not be highlighted.
How do I do this? I know I can do this using the first responder, but I am not sure how to do it.
Would anyone be able to help me out in this?
Thanks
From the apple interface guidlines:
Always provide feedback when users select a list item. Users expect a table row to highlight briefly when they tap a selectable item in it. After tapping, users expect an immediate action to occur: Either a new view appears or the row displays a checkmark to indicate that the item has been selected or enabled.
In rare cases, a row might remain highlighted when secondary details or controls related to the row item are displayed in the same screen. However, this is not encouraged because it is difficult to display simultaneously a list of choices, a selected item, and related details or controls without creating an uncomfortably crowded layout.
I don't think apple will approve an app that leaves a row highlighted (I had an app reject for that very reason). You should perform an action and then immediately unhighlight it. In some rare cases you can leave it highlighted while showing a related view.
However, if you store the current cell you have selected, you can call -deselectRowAtIndexPath:animated: on the tableview to deselect a row.

Can I create UITableView with sub-cells?

Hi I want to create a table view with sub cells. What I mean by "sub cells" is, when I click a arrow pointer in a cell, it should show its sub cells with cell indentation.
Is this kind of cells available in iPhone?
If not, Is this possible to do it in some other way?
This isn't a standard capability of UITableView, but actually isn't that hard to implement. What you need to do is:
Create a custom UITableViewCell (perhaps called 'OutlineTableViewCell'). It should have a disclosure indicator
Create a class which implements the UITableViewDataSource protocol to manage the tree structure of the rows. It should manage the indent level and disclosure state.
Implement methods to expand/collapse sections of the tree (triggered by tapping the disclosure indicator)
Finally, subclass both of these to add the storage and display of your own data in the view
Not sure if that'll work in your case, but in one of my apps, I used the following work around to create a two-level table view with normal (level 1) items toggling (level 2) "sub"-cells:
I have a standard table view, and use its sections as level 1 items.
For each section, I use a custom view with a UIButton to act as the toggle.
I keep track of which sections are toggled on / off through an array, and simply return 0 elements for the section when it's off.
Sub-cells are just regular cells.

iPhone UI controls

Which class is used to create the clickable sections(with > arrow) and the checkbox list on last shot?
alt text http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Art/navigation_interface.jpg
Have a look at the UINavigationController.
To create the list with arrows, use the UITableView and set the Accessory "Disclosure indicator" on the cell (in the Interface builder).
The screenshot is from the Settings application though. If you want to create subpanels for settings, you need to use a different approach (Here is one example)
UITableView (UITableViewController).
The checkmarks and arrows are added by changing the .accessoryType property of the cell. To make the table views clickable, implement the -tableView:didSelectRowAtIndexPath: method in the delegate.