- (void)btnClick:(UIBarButtonItem *)btn
{
//设置表视图是否进入编辑模式
[_tableView setEditing:![_tableView isEditing] animated:YES];
//将导航烂右按钮设置为完成
self.navigationItem.rightBarButtonItem = [_tableView isEditing] ? _finishBtn : _editBtn;
}
***************************************************
//设置cell上面显示的文本信息
//参数1:indexPath.section:指定的分组
//参数2:indexPath.row:指定的行
tc.textLabel.text = [NSString stringWithFormat:@"%li组,%li行",indexPath.section,indexPath.row];
UILabel *label = [[UILabel alloc]init];
label.frame = CGRectMake(200, 5, 100, 30);
label.text = @"测试label";
label.tag = 100;
//加入子视图的时候需要加到cell的contentView上
[tc.contentView addSubview:label];
//设置cell的详细信息(需要设置风格才能显示详情信息)
//UITableViewCellStyleDefault --默认有图片文字
//UITableViewCellStyleValue1, --有图片文字详情
//UITableViewCellStyleValue2, --有文字详情
// UITableViewCellStyleSubtitle--有图片文字详情
tc.detailTextLabel.text = @"详情介绍”;
//设置cell的图标
tc.imageView.image = [UIImage imageNamed:@"tab_c3"];
//设置cell附属视图的类型
//UITableViewCellAccessoryNone,
//UITableViewCellAccessoryDisclosureIndicator,
//UITableViewCellAccessoryDetailDisclosureButton,
//UITableViewCellAccessoryCheckmark,
//UITableViewCellAccessoryDetailButton
tc.accessoryType = UITableViewCellAccessoryCheckmark;
//可以自定义附属视图
tc.accessoryType = [UIButton buttonWithType:UIButtonTypeContactAdd];
UIView *view = [[UIView alloc]init];
view.backgroundColor = [UIColor redColor];
//设置选中的cell的背景视图
tc.selectedBackgroundView = view;
//设置cell的背景图片
tc.backgroundView = [UIImage imageNamed:@"111.jpg”];
*************************当点击cell时调用这个方法*************************
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath