149

This should be simple enough.

I have an iPhone app with a TableView. How do I add the little classic arrow to the righthand side of each cell?

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
Eric Brotto
  • 53,471
  • 32
  • 129
  • 174

9 Answers9

337

Just set the respective accessoryType property of UITableViewCell.

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

In Swift 3,

cell.accessoryType = .disclosureIndicator
EmptyStack
  • 51,274
  • 23
  • 147
  • 178
72

You can do this in Interface Builder. Simply click click on the Table View, go to Prototype Cells on the right side and make it 1. Then click that Prototype Cell and on the right look for Accessory. In the drop-down, click Disclosure Indicator.

Interface Builder example

rzv
  • 2,022
  • 18
  • 22
  • I cannot see anything like "Prototype cells" in my xCode... Is it available in some versions of xCode? – Rasto Aug 22 '13 at 11:47
  • I also cannot find "Prototype Cells". I've used cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; in custom cell. – Arkady Dec 15 '13 at 16:18
  • 1
    hey @rzv can you enlarge the image just a bit more? i forgot my glasses – abbood Sep 06 '14 at 11:04
8

IN SWIFT 5

Use

cell.accessoryType = .detailButton

for a small Info-button on the right. enter image description here

cell.accessoryType = .disclosureIndicator

for a small Info-arrow on the right. enter image description here

cell.accessoryType = .detailDisclosureButton

for a small Info-button and Info-arrow on the right. enter image description here

infront of your return cell

Tonkyboy
  • 91
  • 1
  • 3
7

You can set little classic arrow like two way as below

1) Using inbuilt accessory type method of UITableViewCell

[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; 

2) Creating own accessory view with own image

(I) Drag & drop an arrow image(i.e. circle_arrow_right.png) in your project

(II) In cell design method for every row as below

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

Write below code:

if (cell ==nil) {
    cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:CellIdentifier]autorelease];

    //For creating custom accessory view with own image
    UIImageView *accessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    [accessoryView setImage:[UIImage imageNamed:@"circle_arrow_right.png"]];
    [cell setAccessoryView:accessoryView];
    [accessoryView release];

    //Your other components on cells
     .............
    .............

 }

[Note: Choose appropriate images for accessory view and add in your desired cells. Choose small images for accessory views for better performance.]

Lalit Kumar Maurya
  • 5,475
  • 2
  • 35
  • 29
5

Swift 3:

cell.accessoryType = .disclosureIndicator
David Seek
  • 16,783
  • 19
  • 105
  • 136
4

for simple arrow:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

and for detailed arrow:

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
Ravi_Parmar
  • 12,319
  • 3
  • 25
  • 36
4

Use the accessoryType property of the cell to show a arrow on the right side. See this.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
Mridul Kashatria
  • 4,157
  • 2
  • 18
  • 15
3

The other way to do this is to specify UITableViewCellAccessoryDisclosureIndicator when you create the cell. To do this you'll likely alloc init your cell in the tableViewCellWithReuseIdentifier delegate method (then proceed to customize and configure your cell).

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellAccessoryDisclosureIndicator reuseIdentifier:identifier];
Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
1

Best way is select Disclosure Indicator in Accessory section.

Uditha Prasad
  • 695
  • 5
  • 13