gpt4 book ai didi

ios - 如何滑动以删除特定部分中的行

转载 作者:行者123 更新时间:2023-11-28 19:11:01 24 4
gpt4 key购买 nike

我有两个数组。每个数组都有一个部分。当用户滑动该行并选择删除时,它必须删除右侧部分中的相应行。如何更改我的代码以使其在正确的部分中删除。 到目前为止,这是我的代码。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If you're data source is an NSMutableArray, do this
if (self.numberOfSections == 1)
{
[self.playerNames removeObjectAtIndex:indexPath.row];
}
else
{
//code here needs to determine which section needs to be deleted
}
[self.tableView reloadData];
}
}

最佳答案

尝试改变

if (self.numberOfSections == 1)

到:

if (indexPath.section == 1)

希望对您有所帮助。

关于ios - 如何滑动以删除特定部分中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15518102/

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