tableView里删除单元格

时间:2022-09-25 05:32:19

tableView里删除单元格

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

staticNSString*reuse =@"reuse";

DetaileCell*cell = [tableView
dequeueReusableHeaderFooterViewWithIden
tifier:reuse];

if(!cell ) {
cell = [[DetaileCellalloc]

initWithStyle:UITableViewCellStyleDefau
lt reuseIdentifier:reuse];

cell.model= [self.subArray
objectAtIndex:indexPath.row];

}

return cell;
}

-(void)tableView:(UITableView
*)tableView
didSelectRowAtIndexPath:(NSIndexPath
*)indexPath
{
NSLog(@"shan");

UIAlertView*alerV = [[UIAlertView alloc] initWithTitle:@"是否删除" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];

alerV.tag= indexPath.row;

[alerV show]; }

- (void)alertView:(UIAlertView
*)alertView
clickedButtonAtIndex:(NSInteger)buttonI
ndex

{
if(buttonIndex ==0) {

NSLog(@"确定");

Model*model =
self.subArray[alertView.tag];

[DB deleteModel:model.time];

        [self.subArray
removeObjectAtIndex:alertView.tag];

[self.taleV reloadData]; }

}