iOS8 UITableViewCell行高仅在第一次时不正确
这是CellForRowatinex代码iOS8 UITableViewCell行高仅在第一次时不正确,uitableview,ios8,Uitableview,Ios8,这是CellForRowatinex代码 static NSString *ClipCellIdentifier = @"HomeClipCell"; HomeClipCell *clipCell = [tableView dequeueReusableCellWithIdentifier:ClipCellIdentifier]; [clipCell setUSeparatorStyle:SeparatorStyle_Top]; if (ind
static NSString *ClipCellIdentifier = @"HomeClipCell";
HomeClipCell *clipCell = [tableView dequeueReusableCellWithIdentifier:ClipCellIdentifier];
[clipCell setUSeparatorStyle:SeparatorStyle_Top];
if (indexPath.section==2) {
[clipCell setClipInfoArray:_clipsArray];
[clipCell setClickBlock:^(NSInteger index) {
VodInfo *vodInfo = weakSelf.clipsArray[index];
VideoDetailViewController *detailView = [weakSelf viewControllerWithIdentifier:@"VideoDetailViewController"];
[detailView setVodInfo:vodInfo];
[detailView setRootViewController:weakSelf.rootViewController];
[weakSelf.navigationController pushViewController:detailView animated:YES];
}];
}else {
[clipCell setClipInfoArray:_mostPopArray];
[clipCell setClickBlock:^(NSInteger index) {
VodInfo *vodInfo = weakSelf.mostPopArray[index];
VideoDetailViewController *detailView = [weakSelf viewControllerWithIdentifier:@"VideoDetailViewController"];
[detailView setVodInfo:vodInfo];
[detailView setRootViewController:weakSelf.rootViewController];
[weakSelf.navigationController pushViewController:detailView animated:YES];
}];
}
[clipCell setNeedsUpdateConstraints];
[clipCell updateConstraintsIfNeeded];
return clipCell;
这很奇怪。第2部分中的单元格显示得很好。但在另一种情况下,第一次显示的单元格高度为44。第二次(滚动tableView),显示的是正确的
我还发现了来自dequeueReusableCellWithIdentifier的单元格:大小不同。在第2节中,单元格高度是正确的大小,但其他单元格的高度是44
有人能帮我吗?谢谢
*添加信息*
这只发生在我的iPhone5s上。在iPhone6模拟器中,它也能很好地显示。行高是非负的,用点表示。如果代理未实现tableView:heightForRowAtIndexPath:方法,则可以设置单元格的行高。如果未明确设置行高,UITableView会将其设置为标准值 使用tableView:heightForRowAtIndexPath:而不是rowHeight会影响性能。每次显示表视图时,它都会为其每一行在代理上调用tableView:heightForRowAtIndexPath:,这可能会导致具有大量行(大约1000行或更多行)的表视图出现严重的性能问题 来自苹果
试着实现这个方法,也许它会解决这个问题我在其他部分有动态单元格。行高会破坏它们。