【问题标题】:Make 2 UIScrollViews zoom and scroll identically使 2 个 UIScrollViews 缩放和滚动相同
【发布时间】:2013-09-11 13:44:47
【问题描述】:

我有一个有两个 UIScrollViews 的屏幕。滚动视图内部是一个可缩放的 UIImageView。

我想在一个滚动视图中实现相同的滚动和缩放,以应用于另一个滚动视图。即,如果用户平移图像,两个滚动视图都以完全相同的速率平移图像。如果用户捏合将图像放大,另一个放大完全相同的量。

我在这里阅读了有关使用 zoomToRect:animated: 调用的信息。我不确定如何实现它,所以我尝试了以下方法 - 但它似乎没有产生正确的结果。注意。 scrollView 包含 self.imageViewLeft。 self.scrollViewRight 是没有被触摸的scrollView。

- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
    CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:self.imageViewLeft];
    [self.scrollViewRight zoomToRect:visibleRect animated:false];
}

【问题讨论】:

    标签: ios objective-c uiviewcontroller uiscrollview


    【解决方案1】:

    我解决了伙计们!给我的道具。

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
        if (scrollView == self.scrollViewLeft) {
            [self.scrollViewRight setZoomScale:[scrollView zoomScale]];
            [self.scrollViewRight setContentOffset:[scrollView contentOffset]];
        } else {
            [self.scrollViewLeft setZoomScale:[scrollView zoomScale]];
            [self.scrollViewLeft setContentOffset:[scrollView contentOffset]];
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-20
      • 2011-07-04
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      • 2011-08-23
      • 2018-06-15
      • 2012-07-25
      相关资源
      最近更新 更多