//要求委托方的編輯風(fēng)格在表視圖的一個特定的位置。
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
//默認(rèn)沒有編輯風(fēng)格
UITableViewCellEditingStyle result = UITableViewCellEditingStyleNone;
if ([tableView isEqual:_tableView])
{
//設(shè)置編輯風(fēng)格為刪除風(fēng)格
result = UITableViewCellEditingStyleDelete;
}
return result;
}
-(void)setEditing:(BOOL)editing animated:(BOOL)animated{
//設(shè)置是否顯示一個可編輯視圖的視圖控制器。
[super setEditing:editing animated:animated];
//切換接收者的進(jìn)入和退出編輯模式。
[self.tableView setEditing:editing animated:animated];
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
//請求數(shù)據(jù)源提交的插入或刪除指定行接收者。
if (editingStyle ==UITableViewCellEditingStyleDelete)
{? //如果編輯樣式為刪除樣式
if (indexPath.row<[self.arrayShareList count])
{
//移除數(shù)據(jù)源的數(shù)據(jù)
[self.arrayShareList removeObjectAtIndex:indexPath.row];
//移除tableView中的數(shù)據(jù)
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
}
}