[英]Different UITableView scrolling performance on iPad 2 & iPhone 4s
Solved 解决了
There was a shadow on the self.view layer. self.view层上有一个阴影。 After removed it, the tableview scrolls smoothly (56-59fps).
删除后,表格视图会平滑滚动(56-59fps)。
The problem I got is so weird. 我遇到的问题太奇怪了。
I am building a UITableView based Twitter like App. 我正在建立一个基于UITableView的Twitter,例如App。 After optimized the table view loading and scrolling, I tested the App (same code & same UI) on both iPad 2 and iPhone 4S.
优化表格视图的加载和滚动后,我在iPad 2和iPhone 4S上测试了该应用程序(相同的代码和相同的UI)。 On the iPad 2, I got 56-59fps smooth scrolling animation.
在iPad 2上,我获得了56-59fps的平滑滚动动画。 But on the iPhone 4S, I got only 43-49fps scrolling animation, which is awful.
但是在iPhone 4S上,我只有43-49fps的滚动动画,这太糟糕了。
This seems not caused by the Retina display. 这似乎不是视网膜显示屏引起的。 After I remove all images from cells, the problem is still there.
从单元格中删除所有图像后,问题仍然存在。 The following is the code of cellForRowAtIndexPath
以下是cellForRowAtIndexPath的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// fetch note from the fetched results controller
Note *note = [self.fetchedResultsController objectAtIndexPath:indexPath];
if ([note.photos count] > 0) {
static NSString *CellIdentifier = @"Photo Cell";
PhotoCell *cell = (PhotoCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[PhotoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
} else {
[cell clearContents];
}
NSNumber *currentRowNumber = [NSNumber numberWithInt:indexPath.row];
// check if the photos of this cell has been pre loaded
NSDictionary *coverImages = [self.coverImagesForNotes objectForKey:currentRowNumber];
if (coverImages == nil) {
if (self.tableView.dragging == NO && self.tableView.decelerating == NO) {
coverImages = [self loadCoverImagesForCell:indexPath photos:note.photos];
[self.coverImagesForNotes setObject:coverImages forKey:currentRowNumber];
}
}
// assign contents to the cell
[self compositeContentView:cell forNote:note rowNumber:indexPath.row];
// refine
unsigned textContentHeight = [[self.cellTextHeightDict objectForKey:currentRowNumber] integerValue];
unsigned currentPageNumber = [self currentPageNumberAtRow:indexPath.row];
[cell initPhotoVideoView:textContentHeight photos:note.photos coverImages:coverImages showPage:currentPageNumber rowNumber:indexPath.row];
cell.delegate = self;
return cell;
} else {
static NSString *CellIdentifier = @"Simple Cell";
BaseCell *cell = (BaseCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[OneViewBaseCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// assign contents to the cell
[self compositeContentView:cell forNote:note rowNumber:indexPath.row];
return cell;
}
}
Thanks for answers. 感谢您的回答。
Are you using images in your table view cells? 您是否在表格视图单元格中使用图像? This will be more expensive on a retina display.
在视网膜显示器上,这将更加昂贵。 Also if you are using images, try to load them in on a background thread which will reduce the latency.
另外,如果您使用的是图像,请尝试将它们加载到后台线程中,这样可以减少延迟。
If you're not using images then you should really look at how you are creating your cells, please post tableView:cellForRowAtIndexPath:
method implementation 如果您不使用图像,那么您应该真正了解如何创建单元格,请发布
tableView:cellForRowAtIndexPath:
方法实现
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.