Adding the little arrow to the right side of a cell in an iPhone TableView Cell

IphoneObjective CIosCocoa TouchUitableview

Iphone Problem Overview


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?

Iphone Solutions


Solution 1 - Iphone

Just set the respective accessoryType property of UITableViewCell.

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

In Swift 3,

cell.accessoryType = .disclosureIndicator

Solution 2 - Iphone

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

Solution 3 - Iphone

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

Solution 4 - Iphone

Swift 3:

cell.accessoryType = .disclosureIndicator

Solution 5 - Iphone

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

Solution 6 - Iphone

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

Solution 7 - Iphone

for simple arrow:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

and for detailed arrow:

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

Solution 8 - Iphone

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];

Solution 9 - Iphone

Best way is select Disclosure Indicator in Accessory section.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEric BrottoView Question on Stackoverflow
Solution 1 - IphoneEmptyStackView Answer on Stackoverflow
Solution 2 - IphonerzvView Answer on Stackoverflow
Solution 3 - IphoneLalit Kumar MauryaView Answer on Stackoverflow
Solution 4 - IphoneDavid SeekView Answer on Stackoverflow
Solution 5 - IphoneTonkyboyView Answer on Stackoverflow
Solution 6 - IphoneMridul KashatriaView Answer on Stackoverflow
Solution 7 - IphoneRavi_ParmarView Answer on Stackoverflow
Solution 8 - IphoneKyle CleggView Answer on Stackoverflow
Solution 9 - IphoneUditha PrasadView Answer on Stackoverflow