UITableView cell的选择删除,取消cell选中后的背景色

来源:互联网 发布:mac装虚拟机win7 编辑:程序博客网 时间:2024/04/28 01:40

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

{


       static NSString *TableSampleIdentifier =@"TravelDetailMessageTableViewCell";

       BOOL registered = NO;

       if(!registered)

        {

            UINib * nib = [UINibnibWithNibName:@"TravelDetailMessageTableViewCell"bundle:nil];

            [tableViewregisterNib:nib forCellReuseIdentifier:TableSampleIdentifier];

            registered =YES;

        }

        

        TravelDetailMessageTableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:

                                           TableSampleIdentifier];

        cell.delegate =self;

//设置取消cell的选中色

        cell.selectionStyle =UITableViewCellSeparatorStyleNone;

       return cell;

        


}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

{

//设置cell编辑时的状态为删除状态

        returnUITableViewCellEditingStyleDelete;

   

}


- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{

   

    if (editingStyle ==UITableViewCellEditingStyleDelete)

    {

    //此处添加删除时要执行的操作

    }

}


- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

{

    //设置编辑时的tip

   return @"删除";

}

0 0
原创粉丝点击