cell左滑刪除一行

//要求委托方的編輯風(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];

}

}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容