gpt4 book ai didi

iphone - 滑动删除 UITableView

转载 作者:可可西里 更新时间:2023-11-01 03:01:15 26 4
gpt4 key购买 nike

如何在滑动时删除 UITableView 行?我知道有人问了这个问题,但我只得到错误。这是代码:

-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath {
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSInteger row = [indexPath row];
[tableDataSource removeObjectAtIndex:row];
}
}

但是没有任何反应。如果您编写代码,我将不胜感激。

最佳答案

更好的做法是只删除选定的行,而不是重新加载所有表格:

 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

关于iphone - 滑动删除 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3987934/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com