我有一个由 UICollectionView 处理的图像网格。我想做的是在选择单元格时通过放大图像转换到另一个视图控制器,并使该图像占据子视图控制器中屏幕的大部分。有什么好的方法可以创建这种行为。
感谢所有的帮助!
我有一个由 UICollectionView 处理的图像网格。我想做的是在选择单元格时通过放大图像转换到另一个视图控制器,并使该图像占据子视图控制器中屏幕的大部分。有什么好的方法可以创建这种行为。
感谢所有的帮助!
在子视图控制器中,您可以添加滚动视图并可以添加类似的属性。
scrollView.bouncesZoom = YES;
scrollView.delegate = self;
scrollView.clipsToBounds = YES;
添加图像视图:-
imageView = [[UIImageView alloc] initWithImage:[UIImage imgnamed:@"image01.png"]];
imageView.userIntractionEnabled = YES;
imageView.autoSizingMask = UIViewAutoresizingFlexibleWidth;
[scrollview addSubView:imageView];
计算最小缩放级别:-
float minimumScale = [scrollView frame].size.width / [imageView frame].size.width;
scrollView.maximumZoomScale = 3.0 // you can exeed as per your requirment
scrollView.minimumZoomScale = minimumScale;
scrollView.zoomScale = minimumScale;
希望这对您有所帮助。如果有任何问题或问题,请在评论中提问。
For this, I would use a custom segue. In the UICollectionView documentation, Apple recommends using a fake cell when moving it across your CollectionView. You can do this with storyboard or programatically. Inside your -prepareForSegue: method, place the image from the selected cell on the screen centered over the cell, then animate the scaling in the segue.
Custom Segue guide: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomSegues/CreatingCustomSegues.html
Ray's site is also boss: http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2