I\'m trying to add a UIScrollView
inside of a UICollectionViewCell
. The idea is that you can use pinch to zoom the UIScrollView
(and w
Please add scrollview in your cell and your current cell image view add in scrollview. then use below code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ImageContext *context = [self.images objectAtIndex:indexPath.row];
ImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"imageCell" forIndexPath:indexPath];
cell.cellScrollView.autoresizesSubviews = YES;
cell.cellScrollView.multipleTouchEnabled =YES;
cell.cellScrollView.maximumZoomScale = 4.0;
cell.cellScrollView.minimumZoomScale = 1.0;
cell.cellScrollView.clipsToBounds = YES;
cell.cellScrollView.delegate = self;
cell.cellScrollView.zoomScale = 1.0;
[cell.imageView setImage:[UIImage imageNamed:context.thumbImageUrl]];
return cell;
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{ NSLog(@"%i",scrollView.subviews.count);
for (UIView *v in scrollView.subviews) {
if ([v isKindOfClass:[UIImageView class]]) {
return v;
}
}
}