CollectionView双击缩放

时间:2016-01-14 08:33:56

标签: ios objective-c

我有一个包含scrollview和imageview的collectionview单元格。目前我的collectionview正在检测双击事件,但在尝试缩放uicollectionview单元格中的图像时,它不会放大。

以下是我的代码。

- (void)tapTwice:(UIGestureRecognizer *)gesture
{

    //on a double tap, call zoomToRect in UIScrollView

    // Note we need to get location of the tap in the imageView coords, not the imageScrollView

    if (gesture.state == UIGestureRecognizerStateEnded)
    {
        CGPoint point = [gesture locationInView:self.mainProductImageCollectionView];
        NSIndexPath *indexPath = [self.mainProductImageCollectionView indexPathForItemAtPoint:point];
        if (indexPath)
        {
                if(mainCell.zoomScrollView.zoomScale > mainCell.zoomScrollView.minimumZoomScale)
                    [mainCell.zoomScrollView setZoomScale:1.0 animated:YES];
                else
                    [mainCell.zoomScrollView setZoomScale:3.0 animated:YES];
            NSLog(@"Image was double tapped");
        }
        else
        {
//            DoSomeOtherStuffHereThatIsntRelated;
        }
    }

}

任何帮助将不胜感激。

提前致谢。

0 个答案:

没有答案