简体   繁体   English

缩放UIScrollView中的多个子视图

[英]Zooming multiple subviews in an UIScrollView

How would I go about zooming multiple subviews of an UIScrollView simultaneously? 我将如何同时缩放UIScrollView的多个子视图? I have a UIScrollView inside another UIScrollView (with paging enabled) and inside the inner scrollview I have four UIImageViews. 我在另一个UIScrollView内有一个UIScrollView(启用了分页),在内部scrollview内有四个UIImageViews。 I would like for the zoom to persist when I scroll to the next page, thus displaying the next image. 我希望缩放在滚动到下一页时保持不变,从而显示下一张图像。

Relevant code follows: 相关代码如下:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.page2;
}
+(void)updateScale:(CGFloat)newScale{
    currentScale = newScale;
}
+(CGFloat)getScale{
    return currentScale;
}

from the outer, paging enabled, scroll view and 从外部,启用分页,滚动视图和

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return imageView;
}
-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{
    [PhotoViewController updateScale:scale];
    NSLog(@"New scale set to %01f", scale);
    NSLog(@"This should be equal to %01f", [PhotoViewController getScale]);
}

from the inner scrollview. 从内部滚动视图。

currentScale is updated correctly according to the log output, but when I call [page setZoomScale:[PhotoViewController getScale]]; currentScale根据日志输出正确更新,但是当我调用[page setZoomScale:[PhotoViewController getScale]]; for the updated page variable, nothing happens. 对于更新后的page变量,什么也没有发生。 page is allocated and initialized correctly. page已正确分配和初始化。

只需将所有图像视图放入一个空的UIView中,然后将该视图添加到滚动视图中即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM