From iPhone Development Wiki
Jump to: navigation, search

UITableView is a view that has a table structure. Almost all iPhoneOS applications are built using table views as the main view.


Multiple-row selection

How multiple row selection looks like.
Signature -(NSArray*)indexPathsForSelectedRows;
Available in 3.0 –

The UITableView supports multiple-row selection natively, but not exposed to public.

There are several steps to enable multiple-row selection. For the cells which the multiple-row selection is desired, make the delegate returns "3" as the editing style for them:

-(UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath {
  return 3;

When a cell is selected or deselected, the corresponding -[id<UITableViewDelegate> didSelectRowAtIndexPath:] and -[id<UITableViewDelegate> didDeselectRowAtIndexPath:] methods will be called respectively. You have to distinguish whether it is a multiple-row selection or normal selection yourself. To obtain all rows the user have selected, use the -[UITableView indexPathsForSelectedRows] method.

There exist SDK-compatible way to get the similar effect. See http://cocoawithlove.com/2009/01/multiple-row-selection-and-editing-in.html.

Modifying the red checkmark

Signature @property(nonatomic,retain) UIColor* multiselectCheckmarkColor;
Available in 3.0 –

The checkmark color in the multiple-row selection by default is red. If you don't like this color, you can change the multiselectCheckmarkColor property. However, the color must be applied to the whole table, not individual cells.

See also