【发布时间】:2014-10-30 14:00:37
【问题描述】:
在这里我放大 Collectionview 单元格图像,当它被选中但现在我想在内部图像视图中进行触摸然后返回到集合视图如何可能请给我解决方案
这是我的代码
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[collectionView selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionCenteredHorizontally];
[self zoomToSelectedImage:indexPath];
}
-(void)zoomToSelectedImage:(NSIndexPath *)indexPath
{
NSDictionary *dict = [self.imagesa objectAtIndex:indexPath.item];
NSString *img=[dict valueForKey:@"link"];
UIImageView *zoomImage = [[UIImageView alloc] init];
[zoomImage sd_setImageWithURL:[NSURL URLWithString:img]];
zoomImage.contentMode = UIViewContentModeScaleAspectFit;
zoomImage.backgroundColor=[UIColor grayColor];
zoomImage.userInteractionEnabled=YES;
UIPinchGestureRecognizer *pinchgesture=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureDetected:)];
[pinchgesture setDelegate:self];
[zoomImage addGestureRecognizer:pinchgesture];
UIPanGestureRecognizer *pangausture=[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGestureDetected:)];
[pangausture setDelegate:self];
[zoomImage addGestureRecognizer:pangausture];
self.imagecollection.hidden=TRUE;
CGRect zoomFrameTo = CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);
UICollectionViewCell *cellToZoom =(UICollectionViewCell *)[self.imagecollection cellForItemAtIndexPath:indexPath];
CGRect zoomFrameFrom = cellToZoom.frame;
[self.view addSubview:zoomImage];
zoomImage.frame = zoomFrameFrom;
zoomImage.alpha = 0.2;
[UIView animateWithDuration:0.01 animations:
^{
zoomImage.frame = zoomFrameTo;
zoomImage.alpha = 1;
} completion:nil];
}
这里的 Imagecollection 是我的 Collectionview。
【问题讨论】:
标签: ios uicollectionview