gpt4 book ai didi

ios - UITableView 动画故障

转载 作者:行者123 更新时间:2023-11-29 03:08:23 24 4
gpt4 key购买 nike

当我重新加载几个带有动画的单元格时,在其他一些非动画单元格之间会出现一个空格。然而,最有趣的是它有时会发生,有时不会。以下代码来自 tableView 委托(delegate)的 didselect 函数。

 NSArray *taskArray;
int count ;
if (array.count >= indexPath.row+1) {
taskArray = [[dictionary objectForKey:[NSString stringWithFormat:@"Week %i",indexPath.section+1]] objectForKey:[array objectAtIndex:indexPath.row]];
count = [taskArray count];
}else{

count = 0;

}
numberOfAddedRows = count;

selectedRow = -1;
selectedSection = -1;


int numberOfRows = [[[dictionary objectForKey:[NSString stringWithFormat:@"Week %i",indexPath.section+1]] allKeys] count];

[self.tableView beginUpdates];





/*for (int i = numberOfRows-1+numberOfAddedRows; i > indexPath.row; i--) {
[array addObject:[NSIndexPath indexPathForRow:i-1 inSection:indexPath.section]];
}*/

if (!editMode) {


[array__ removeAllObjects];
for (int i = indexPath.row+numberOfAddedRows; indexPath.row < i; i--) {

[array__ addObject:[NSIndexPath indexPathForRow:i inSection:indexPath.section]];
}




[self.tableView deleteRowsAtIndexPaths:array__ withRowAnimation:UITableViewRowAnimationMiddle];



}else{

[array__ removeAllObjects];
for (int i = indexPath.row+numberOfAddedRows+1; indexPath.row < i; i--) {
[array__ addObject:[NSIndexPath indexPathForRow:i inSection:indexPath.section]];
}


UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

UITextField *textField = (UITextField*)[cell viewWithTag:2];
[textField resignFirstResponder];




[self.tableView deleteRowsAtIndexPaths:array__ withRowAnimation:UITableViewRowAnimationMiddle];



}





[self.tableView endUpdates];

[self.tableView reloadData];

最佳答案

为什么要写最后一行?

 [self.tableView reloadData];

尝试删除它 - 我认为它会干扰动画。

关于ios - UITableView 动画故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22516062/

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