Sunday, April 3, 2011

How to add an image to the right of rows in TableView on iPhone?

I want to add an arrow to the right of each row in TableView on iPhone. Any ideas how to do this?

From stackoverflow
  • I just worked it out:

    -(UITableViewCellAccessoryType)tableView:(UITableView *)tableView 
         accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewCellAccessoryDetailDisclosureButton;
    }

    -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { //add action here }

    A blue arrow will show up to the right of each row.

  • You mean the default arrow (a chevron) that lots of apps have?

    UITableViewCell *myCell = ...; //GET a cell from somewhere.
    myCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    

0 comments:

Post a Comment