ios - 请教:scrollView中无法用viewForZoomingInScrollView方法缩放
PHP中文网
PHP中文网 2017-04-17 17:56:03
0
3
408

按照教程,在scrollView中使用viewForZoomingInScrollView方法进行图片缩放,编译成功,但是无法缩放。

代码如下:

#import "ViewController.h"

@interface ViewController () <UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"minion"]];
    
    [self.scrollView addSubview:imageView];
    self.scrollView.contentSize = imageView.image.size;
    
    self.scrollView.delegate = self;
    self.scrollView.maximumZoomScale = 3.0;
    self.scrollView.minimumZoomScale = 0.2;

}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    return self.imageView;
}
PHP中文网
PHP中文网

认证0级讲师

reply all(3)
刘奇

The property UIImageView has no value assigned

小葫芦

Can UIImageView be displayed? What about changing it to strong?

In addition, the contentSize of scrollView is set to the size of the image. How big is the size of the image?

黄舟

ScrollView is not initialized...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template