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

后端 未结 9 1361
梦如初夏
梦如初夏 2021-01-29 23:21

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?

9条回答
  •  爱一瞬间的悲伤
    2021-01-29 23:40

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

提交回复
热议问题