- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"点击了删除");
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.infoItems removeObjectAtIndex:(indexPath.row*2)];
[self.infoItems removeObjectAtIndex:(indexPath.row*2)];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"手指撮动了");
return UITableViewCellEditingStyleDelete;
}
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"删除";
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
UITableView滑动删除
最新推荐文章于 2022-07-06 20:33:46 发布
本文介绍了一个使用 Swift 实现的 UITableView 如何处理单元格的删除和编辑功能。具体包括响应删除操作、更新数据源、实现拖动调整顺序等功能。这对于希望在 iOS 应用中实现流畅的列表编辑体验的开发者来说非常实用。
6404

被折叠的 条评论
为什么被折叠?



