
CGPoint pointInCollectionVIEw = [gesture locationInVIEw:self.collectionVIEw];NSIndexPath *selectedindexPath = [self.collectionVIEw indexPathForItemAtPoint:pointInCollectionVIEw];UICollectionVIEwCell *selectedCell = [self.collectionVIEw cellForItemAtIndexPath:selectedindexPath];NSLog(@"Selected cell %@",selectedindexPath);
不确定从哪里开始. UICollectionVIEw应该负责显示放大的单元格吗?或者我应该创建一个新的视图控制器,以全屏显示单元格(图像)的内容?
解决方法 我采用了解决方案 here并稍微修改了它以使用集合视图.我还添加了一个透明的灰色背景来隐藏原始视图(假设图像不占用整个帧).@implementation CollectionVIEwController{ UIImageVIEw *fullScreenImageVIEw; UIImageVIEw *originalimageVIEw;}...// in whatever method you're using to detect the cell selectionCGPoint pointInCollectionVIEw = [gesture locationInVIEw:self.collectionVIEw];NSIndexPath *selectedindexPath = [self.collectionVIEw indexPathForItemAtPoint:pointInCollectionVIEw];UICollectionVIEwCell *selectedCell = [self.collectionVIEw cellForItemAtIndexPath:selectedindexPath];originalimageVIEw = [selectedCell imageVIEw]; // or whatever cell element holds your image that you want to zoomfullScreenImageVIEw = [[UIImageVIEw alloc] init];[fullScreenImageVIEw setContentMode:UIVIEwContentModeScaleAspectFit];fullScreenImageVIEw.image = [originalimageVIEw image];// ***********************************************************************************// You can either use this to zoom in from the center of your cellCGRect tempPoint = CGRectMake(originalimageVIEw.center.x,originalimageVIEw.center.y,0);// OR,if you want to zoom from the tapped point...CGRect tempPoint = CGRectMake(pointInCollectionVIEw.x,pointInCollectionVIEw.y,0);// ***********************************************************************************CGRect startingPoint = [self.vIEw convertRect:tempPoint fromVIEw:[self.collectionVIEw cellForItemAtIndexPath:selectedindexPath]];[fullScreenImageVIEw setFrame:startingPoint];[fullScreenImageVIEw setBackgroundcolor:[[UIcolor lightGraycolor] colorWithAlphaComponent:0.9f]];[self.vIEw addSubvIEw:fullScreenImageVIEw];[UIVIEw animateWithDuration:0.4 animations:^{ [fullScreenImageVIEw setFrame:CGRectMake(0,self.vIEw.bounds.size.wIDth,self.vIEw.bounds.size.height)]; }];UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fullScreenImageVIEwTapped:)];singleTap.numberOfTapsrequired = 1;singleTap.numberOftouchesrequired = 1;[fullScreenImageVIEw addGestureRecognizer:singleTap];[fullScreenImageVIEw setUserInteractionEnabled:YES];...- (voID)fullScreenImageVIEwTapped:(UIGestureRecognizer *)gestureRecognizer { CGRect point=[self.vIEw convertRect:originalimageVIEw.bounds fromVIEw:originalimageVIEw]; gestureRecognizer.vIEw.backgroundcolor=[UIcolor clearcolor]; [UIVIEw animateWithDuration:0.5 animations:^{ [(UIImageVIEw *)gestureRecognizer.vIEw setFrame:point]; }]; [self performSelector:@selector(animationDone:) withObject:[gestureRecognizer vIEw] afterDelay:0.4];}-(voID)animationDone:(UIVIEw *)vIEw{ [fullScreenImageVIEw removeFromSupervIEw]; fullScreenImageVIEw = nil;} 总结 以上是内存溢出为你收集整理的ios – UICollectionView全屏放大UICollectionViewCell全部内容,希望文章能够帮你解决ios – UICollectionView全屏放大UICollectionViewCell所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)