一旦编辑模式开始,我想更改 UITableView 显示的删除文本。
委托方法:
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
仅当第一次显示索引路径处的 deleteButton 时才调用,但如果我的模型在它下面发生更改,我需要更新此文本。是否可以在不重新加载整个部分的情况下再次调用此方法?请参阅下面的代码,并提前感谢您的帮助。
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
ContainerTableViewCell *cell = (ContainerTableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
if ([cell.editPhotos count] > 0) {
return [NSString stringWithFormat:@"Delete %d photos", [cell.editPhotos count]];
}
else{
return @"Delete Section";
}
}
在某些上下文中,我有一个嵌套在uiatevieviewcell中的UicollectionView,选择单元格时将发送通知。我尝试使用以下内容重新加载该部分:
[self.tableView reloadRowsAtIndexPaths:@[[self.tableView indexPathForCell:cell]] withRowAnimation:UITableViewRowAnimationNone];
但这是不可取的,因为它会导致 tableview 跳转并且无法正确显示选择。我也试过:
[self.tableView.delegate tableView:self.tableView titleForDeleteConfirmationButtonForRowAtIndexPath:[self.tableView indexPathForCell:cell]];
绝望中。虽然这确实会导致调用正确的方法,但它不会更改删除文本。