gpt4 book ai didi

iphone - UIScrollView 不响应 setZoomScale :

转载 作者:行者123 更新时间:2023-12-03 18:41:08 28 4
gpt4 key购买 nike

我做错了什么?这是我如何创建+填充我的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,图像以全尺寸清晰显示。双指缩放没有任何作用。我几乎尝试了网上能找到的所有方法,但似乎每个人都在这样做,而且这对他们有用。

非常感谢您的帮助!

最佳答案

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

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

查看   the documentation

关于iphone - UIScrollView 不响应 setZoomScale :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1817917/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com