0

我有一个带有一堆图像的 UIScrollView。到目前为止,我已经设法在布局更改时更改滚动视图及其 UIImageViews 的大小。但问题是,当布局发生变化时,图像似乎“摆动”而不是围绕其中心点旋转。这看起来很奇怪,我看到许多具有这种分页的应用程序已经在图像视图上实现了平滑的布局更改动画。我如何实现这一目标?

代码是这样的:

viewDidLoad
{
     // Set up scrollview subviews and their content offsets based on NSArray

     // Set up orientation change listener
}

orientationChangeListener
{
     UIImageView *iv = [self.ivScrollView.subviews objectAtIndex: self.ivPager.currentPage];

     self.ivScrollView.layer.anchorPoint = iv.layer.anchorPoint;

     [self.ivScrollView setContentOffset: CGPointMake(self.ivScrollView.frame.size.width * self.current, 0.0) animated:NO
 ];

    switch(orientation){

        case portrait:

              // update scrollview's subview sizes and content offsets
              // code to position the image appropriately based on screen dimensions

               break;

       case landscapeLeft:

              // update scrollview's subview sizes and content offsets
              // code to position the image appropriately based on screen dimensions

               break;

       case landscapeRight:

              // update scrollview's subview sizes and content offsets
              // code to position the image appropriately based on screen dimensions

               break;

    }

}

我希望这能给你这个想法。:)

4

1 回答 1

0

这是以防有人遇到此问题并碰巧找到此页面:

经过大量研究,我终于按照这个视频WWDC 2010 Video: Designing Apps with Scrolls Views中的说明解决了这个问题

Also, after following everything in the video I had to set this property in each of the Zoomable scrollviews which displayed the images:

myZoomableScrollview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
于 2013-01-11T10:03:32.060 回答