gpt4 book ai didi

ios - 禁止一个 UITableViewCell 被编辑

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

嘿伙计们,我目前正试图阻止一个 tableviewcell 被编辑。但是我在互联网上找到的解决方案无法正常工作。这是我使用的代码:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.

if (indexPath.section == 1) {
if (indexPath.row == self.results.count+1) {
return NO;
}
}

return YES;
}

这里的问题是 tableview 单元格不再是可编辑的,但它仍然显示红色如果我像这样启用我的 tableview 的编辑样式,则删除角标(Badge):

- (void) barButtonItemEditPressed: (id) sender
{
[self.navigationController setToolbarHidden:NO animated:YES];
[self.tableView setEditing:YES animated:YES];
[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:self.barButtonItemDone, nil] animated:YES];
[self.navigationItem setLeftBarButtonItem:self.barButtonItemCancel animated:YES];
}

那么我做错了什么?

最佳答案

你还需要添加编辑样式

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{

}

关于ios - 禁止一个 UITableViewCell 被编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14354261/

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