2
解決不同的UITableView滾動性能的iPad 2&iPhone 4S
有所述self.view層上的陰影。刪除它後,表格視圖平滑滾動(56-59fps)。
我得到的問題太奇怪了。
我正在構建一個基於UITableView的Twitter應用程序。在優化了表格視圖加載和滾動之後,我在iPad 2和iPhone 4S上測試了應用程序(相同的代碼&相同的用戶界面)。在iPad 2上,我有56-59fps的平滑滾動動畫。但在iPhone 4S上,我只有43-49fps的滾動動畫,這很糟糕。
這似乎不是由視網膜顯示引起的。從單元格中刪除所有圖像後,問題仍然存在。以下是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;
}
}
感謝您的回答。
感謝您的諮詢! –