在tableView中设置cell的图片和文字

// 设置UITableViewCellEditingStyle的 accessoryType

  UITableViewCellAccessoryNone,                   // don't show any accessory view

    UITableViewCellAccessoryDisclosureIndicator,    // regular chevron. doesn't track

    UITableViewCellAccessoryDetailDisclosureButton, // info button w/ chevron. tracks

    UITableViewCellAccessoryCheckmark,              // checkmark. doesn't track

    UITableViewCellAccessoryDetailButton

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

{

    static NSString *ID = @"yxcell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];

    if (cell == nil) {

        cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:ID];

        cell.textLabel.backgroundColor = [UIColorclearColor];

        cell.detailTextLabel.backgroundColor = [UIColorclearColor];

        cell.detailTextLabel.font = [UIFontsystemFontOfSize:14];

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

//        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        

        // cell的背景颜色

        UIView *bg = [[UIView alloc] init];

        bg.backgroundColor = [UIColorbrownColor];

        cell.backgroundView = bg;

        // cell选中的时的背景颜色

        UIView *bgv = [[UIView alloc]init];

        bgv.backgroundColor = [UIColorredColor];

        cell.selectedBackgroundView = bgv;

    }

//    UIImage *image = [UIImage imageNamed:@"111.jpg"];

//  cell.imageView.image = image;

    cell.imageView.image = [UIImageimageNamed:@"111.jpg"] ;

    cell.textLabel.text = @"smile集团";

    cell.detailTextLabel.text = @"看清楚了";

    

    return cell;

}

原文地址:https://www.cnblogs.com/ZGSmile/p/3623113.html