开发者

Question about iPad/iPhone controls

On the iPhone/iPad in the general settings they have a list of itms that display a '>' at the right hand side. When pressed it slides to another view.

Is this a control from the object palette? If so, which control? If not, what is the best way to achieve similar functionality.

I have looked at a lot of the samples on the Apple Dev site, but I cannot find a control like that, or at leas开发者_如何学Got I don't remember seeing it.

Any help on this foolish question is appreciated!! -:)

Thanks


Any time you see a view that is a scrollable list of items, you are looking at a UITableView, and each item in the list is defined using a UITableViewCell. To make the UITableViewCell show the '>', you simply have to set its 'accessoryType' to 'UITableViewCellAccessoryTypeDisclosureIndicator'.

This only draws the '>', it doesn't slide in the other view. However, when a user selects a UITableViewCell, it will call a function on its delegate:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

In here, you will write the logic that slides in the new view controller (using UINavigationController's -pushViewController:animated:).

To learn more about how to use UITableView, I would highly suggest reading through the UITableView programming guide. It also links to downloadable projects with sample code.


You probably mean the combination of a UITableViewController and a UINavigationController. Create a new "navigation based app" to check out how it works & have fun. :)

Both are available in IB under the Controllers section.


The control you're looking for is a UITableview with disclosure indicators. To get the disclosure indicators (either the grey chevrons or the blue buttons), set editingAccessoryType for each tableview cell. That will give you a '>' on the right side of each item in your tableview.

When you tap on one of the '>'s, the tableview's delegate will have this method called:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

This is different from the method that is called if you tap anywhere else on the row:

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath

As dominostars said, you create another view and use UIViewController's pushViewController method to have another view slide in from the right.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜