UIScrollView + UIImage和缩放:不流畅 [英] UIScrollView + UIImage and zoom: not fluid
问题描述
我有视图控制器,里面有一个 UIScrollView
,用于管理缩放,以及 UIImage
。
现在我用处理缩放效果UIScrollViewDelegate
委托和方法 viewForZoomingInScrollView:
...但是结果很差,绝对不流畅!
I have view controller, and inside that I have a UIScrollView
, for managing the zoom, and a UIImage
.
Now I'm handling the zoom effect with UIScrollViewDelegate
delegate and method viewForZoomingInScrollView:
... but the result is very poor, definitely not fluid!
这是我的代码:
#import "ImageViewController.h"
@interface ImageViewController () <UIScrollViewDelegate, UIActionSheetDelegate>
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
@implementation ImageViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.scrollView.delegate = self;
self.scrollView.maximumZoomScale = 3.0;
// some code
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.imageView;
}
// last update
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
if ([self.scrollView zoomScale] < 1.0) {
[self.scrollView setZoomScale:1.0];
}
}
// some other methods...
@end
这是故事板视图:
我没有使用Pinch手势识别器。
所有图片都非常小,如640x480。
I'm not using a Pinch Gesture Recognizer. All images are quite small like 640x480.
谢谢
P.S。这是 UICollectionView和图片的继续。
P.S. this is a continue of UICollectionView and images.
推荐答案
查看此我写的教程。第一部分正是您需要实现的。
Checkout out this tutorial I wrote. The first part is exactly what you need to implement.
这篇关于UIScrollView + UIImage和缩放:不流畅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!