gpt4 book ai didi

iphone - 我是否误解了 reloadRowsAtIndexPaths :

转载 作者:行者123 更新时间:2023-12-03 18:31:56 27 4
gpt4 key购买 nike

我有一个分组 TableView ,我想在其中重新加载特定行。当我调用 reloadRowsAtIndexPaths: 时,该行从 TableView 中完全消失。我还需要做其他事情吗?

//this is the method doing the reload
-(void)setDurationTableViewCell:(NSString *)dur {

self.workoutDuration = dur;
NSIndexPath *durPath = [NSIndexPath indexPathForRow:3 inSection:0];
NSArray *paths = [NSArray arrayWithObject:durPath];
[woTableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationRight];

}//end setDurationTableViewCell


//this is the cellForRowAtIndexPath method if it has anything to do with my issue
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell;

if (indexPath.row == 0) {

//workout comments
cell = [tableView dequeueReusableCellWithIdentifier:@"workoutCommentsCell"];
if (nil == cell) {
cell = workoutCommentsCell;
cell.selectionStyle = UITableViewCellStyleValue1;
}

}else if (indexPath.row == 1) {

//difficulty
cell = [tableView dequeueReusableCellWithIdentifier:@"workoutDifficultyCell"];
if (nil == cell) {
cell = workoutDifficultyCell;
cell.selectionStyle = UITableViewCellStyleValue1;
}
cell.textLabel.text = [NSString stringWithFormat:@"Difficulty: %@", self.workoutDifficulty];

}else if (indexPath.row == 2) {

//workoutDate
cell = [tableView dequeueReusableCellWithIdentifier:@"workoutDateCell"];
if (nil == cell) {
cell = workoutDateCell;
cell.selectionStyle = UITableViewCellStyleValue1;
}
cell.textLabel.text = [NSString stringWithFormat:@"Date: %@", self.workoutDate];

}else if (indexPath.row == 3) {

//workoutDuration
cell = [tableView dequeueReusableCellWithIdentifier:@"workoutTimerCell"];
if (nil == cell) {
cell = workoutTimeCell;
cell.selectionStyle = UITableViewCellStyleValue1;
}
cell.textLabel.text = [NSString stringWithFormat:@"Duration: %@", self.workoutDuration];

}//end else-if


return cell;

}//end cellForRowAtIndexPath

最佳答案

尝试将 ReloadRowsAtIndexPaths 包裹在里面

[self.tableView beginUpdates];
[self.tableView endUpdates];

例如

[self.tableView beginUpdates];
[woTableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationRight];
[self.tableView endUpdates]

关于iphone - 我是否误解了 reloadRowsAtIndexPaths :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1722197/

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