UIScrollView不响应setZoomScale: [英] UIScrollView doesn't respond to setZoomScale:

查看:41
本文介绍了UIScrollView不响应setZoomScale:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做错了什么?这是我创建+填充scrollView的方法

What am I doing wrong? Here is how I create + populate my scrollView

    -(void)viewDidAppear:(BOOL)animated {

    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bigimage.jpg"]];
    imgView.contentMode = UIViewContentModeScaleAspectFit;

    scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
    scrollView.contentSize = imgView.frame.size;

    scrollView.minimumZoomScale =  scrollView.frame.size.width / scrollView.contentSize.width * 0.99;
    scrollView.maximumZoomScale =  2;

    [self.view addSubview:scrollView];


[scrollView addSubview:imgView];

    [scrollView setZoomScale:0.5 animated:YES];
    NSLog(@"current zoomScale: %f", scrollView.zoomScale);
    [imgView release];
}

NSLogged zoomScale为1.0,图像以完整尺寸清晰显示.捏缩放不会执行任何操作.我已经尝试了几乎可以在网上找到的所有内容,但是似乎每个人都在做这件事,并且对他们有用.

The NSLogged zoomScale is 1.0, and the image is clearly shown at full size. Pinch zoom does not do anything. I've tried almost everything I can find on the net, but everybody seems to be doing exactly this, and it works for them.

非常感谢您的帮助!

推荐答案

除非 delegate 属性设置为有效的 UIScrollViewDelegate,否则 UIScrollView 不会缩放响应

A UIScrollView will not zoom unless it has its delegate property set to a valid UIScrollViewDelegate that responds to

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;

签出

Check out  the documentation.

这篇关于UIScrollView不响应setZoomScale:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆