gpt4 book ai didi

ios - willSelectRowAtIndexPath 不改变 detailTextLabel

转载 作者:行者123 更新时间:2023-11-29 02:50:12 26 4
gpt4 key购买 nike

我正在使用 willSelectRowAtIndexPath 委托(delegate)方法来更改所选单元格的 detailTextLabel,即将 \U0001F44D 分配给 选定单元格的detailTextLabel.text并将@""分配给先前选定的单元格,问题在于先前的单元格被分配了@""\U0001F44D没有出现在新选中的单元格上,代码如下:

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSIndexPath *index = [NSIndexPath indexPathForRow:self.selectedCalcMethod inSection:0]; // index of previously selected cell

[self.mainTable cellForRowAtIndexPath:index].detailTextLabel.text=@"";
[self.mainTable cellForRowAtIndexPath:indexPath].detailTextLabel.text =@"\U0001F44D";

return indexPath;
}

最佳答案

切勿像那样直接更改单元格内的任何值。更改您的模型(基础数据),然后在选择发生后(即在运行循环完成后)调用表上的reloadData,以便表 < em>通过以通常方式调用 cellForRowAtIndexPath: 来获取正确的新值。

关于ios - willSelectRowAtIndexPath 不改变 detailTextLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24641698/

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