2

我有与UICollectionView的生涩滚动的问题。我的单元由图片和几个文本标签组成。生涩滚动标签

我试图检查是什么原因造成这一点,当我的标签禁用所有文字设置为平滑,当我两个多标签滚动设置文本又是干...

有谁知道如何解决这个问题?

这里是我的代码:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 

    static NSString *CellIdentifier = @"ResultCell"; 
    ResultCellView *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; 
    if ([self.artworksSavedForLater containsObject:indexPath]) { 
     cell.saveForLaterButton.selected = YES; 
    } else cell.saveForLaterButton.selected = NO; 
    Artwork *artwork = [self.dataHelper.fetchedResultsController objectAtIndexPath:indexPath]; 
    cell.title.text = artwork.title; 


    cell.owner.text = artwork.owner; 
    cell.fields.text = artwork.fields; 
    cell.numberOfViews.text = [NSString stringWithFormat:@"%@",artwork.views]; 
    cell.numberOfLikes.text = [NSString stringWithFormat:@"%@",artwork.likes]; 
    cell.numberOfComments.text = [NSString stringWithFormat:@"%@",artwork.comments]; 
    cell.publishedDate.text = artwork.publishedDate; 
    if ([artwork.hasThumbnail boolValue]) { 
     dispatch_queue_t downloadQueue = dispatch_queue_create("imagecache", NULL); 
     dispatch_async(downloadQueue, ^{ 
      UIImage *productImage = [UIImage imageWithData:artwork.thumbnail]; 
      CGSize imageSize = productImage.size; 
      UIGraphicsBeginImageContext(imageSize); 
      [productImage drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)]; 
      productImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 
      dispatch_async(dispatch_get_main_queue(),^{ 
       cell.thumbnailImage.image = productImage; 
       cell.thumbnailImage.hidden = NO; 
      }); 
     }); 


    } 
    else { 
     cell.thumbnailImage.hidden = YES; 
     [self startOperationsForPhotoRecord:artwork atIndexPath:indexPath]; 

    } 




    return cell; 

代码为我的电池:

- (void)didMoveToSuperview { 
    [super didMoveToSuperview]; 



    self.title.font = [UIFont fontWithName:@"VerbRegular" size:14.0]; 

    self.layer.borderColor = [UIColor colorWithWhite:0.19f alpha:1.0f].CGColor; 
    self.layer.borderWidth = 1.0f; 

    self.layer.rasterizationScale = [UIScreen mainScreen].scale; 
    self.layer.shouldRasterize = YES; 



} 

- (void)prepareForReuse 
{ 
    [super prepareForReuse]; 
    self.thumbnailImage.image = nil; 
} 
+0

的意见,并喜欢在核心的客户关系数据? – wattson12

+0

否 - 所有数据都存储为同一个实体的属性 – matthewfx

+0

使用仪器运行应用程序并查看大部分时间花费的位置。你在单元格的setter方法中做了什么工作?如果您评论图像处理能力是否有所提高? – wattson12

回答

2

我已经找到了解决方案,以生涩滚动的UICollectionView有许多标签动态设置。

而不是使用标签我画使用米罗斯拉夫·胡达克在这个职位描述drawLabel方法的所有NSString的的:

How to change color of NSString in drawAtPoint

现在我UICollectionView顺利滚动:)