im使用UICollectionView爲表示使用SDWebImage這是非常乾和滾動不平穩的圖像的列表。有關如何繼續操作的任何建議?的iOS:UICollectionView小區負荷是非常幹
下面是
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
NSString * cellIdentifier = @"offersCell";
HotDealsCollectionViewCell * cell = (HotDealsCollectionViewCell *)[self.productsCollectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.layer.shouldRasterize = YES;
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
cell.layer.shadowColor = [[UIColor colorWithRed:210.0/255.0 green:210.0/255.0 blue:210.0/255.0 alpha:1.0] CGColor];
cell.layer.shadowOffset = CGSizeMake(2.0f, 2.0f);
cell.layer.shadowRadius = 3.0f;
cell.layer.shadowOpacity = 1.0f;
cell.layer.masksToBounds = NO;
CGRect shadowFrame = cell.layer.bounds;
CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:shadowFrame].CGPath;
cell.layer.shadowPath = shadowPath;
cell.backgroundColor = [UIColor whiteColor];
if ([self.productsArray count] > 0) {
Product * product = [self.productsArray objectAtIndex:indexPath.item];
cell.productName.text = product.productName;
cell.productEndDate.hidden = NO;
cell.productImageView.clipsToBounds = YES;
cell.productEndDate.textAlignment = NSTextAlignmentCenter;
[cell.productImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", product.productImage]] placeholderImage:[UIImage imageNamed:@"noProduct"]];
}
return cell;
}
cell.layer.shouldRasterize = YES; cell.layer.rasterizationScale = [UIScreen mainScreen] .scale; http://stackoverflow.com/questions/16454160/uicollectionview-has-slow-jerky-loading-of-images-and-scrolling –
請發表您的'cellForItemAtIndexPath'代碼。 – iPeter
@MuhammadRaheelMateen我試過這個..但它沒有工作.. – user3355310