- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell2";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
AsyncImageView *recipeImageView = (AsyncImageView *)[cell viewWithTag:100];
UILabel *titleView = (UILabel *)[cell viewWithTag:101];
titleView.numberOfLines = 3;
UIImageView *overlay = (UIImageView *)[cell viewWithTag:111];
FXBlurView *blurView = (FXBlurView *)[cell viewWithTag:110];
blurView.tintColor = [UIColor colorWithRed:51.0 green:51.0 blue:51.0 alpha:1];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
hi = [self videoTitle];
images = [self firstPhoto];
// switch to a background thread and perform your expensive operation
// switch back to the main thread to update your UI
dispatch_async(dispatch_get_main_queue(), ^{
NSString *imgSrc;
NSString *url = images[indexPath.row];
imgSrc = url;
if (imgSrc != nil && [imgSrc length] != 0 ) {
[recipeImageView setImageWithURL:[NSURL URLWithString:images[indexPath.row]] placeholderImage:[UIImage imageNamed:@"red.png"]];
}
else {
NSLog(@"noimage");
recipeImageView.image = [UIImage imageNamed:@"red.png"];
}
titleView.text = hi[indexPath.row];
});
});
return cell;
// recipeImageView.image = [UIImage imageNamed:[videoList objectAtIndex:indexPath.row]];
}
有什么想法吗?谢谢。