Iphone Nimbus NIPagingScrollView和旋转上的重新布局
我正在使用NIPagingScrollView在iPhone上显示几个页面 每次我轻弹到一个页面,下一个页面也是预加载的,这很好 当我将iPhone从纵向模式旋转到横向模式时,我让LayoutSubView在我的NIPageView子类中进行重新布局。NIPagingScrollView设置为自动拉伸宽度和高度以保持全屏。这适用于当前页面 但是当我切换到下一页时,布局被破坏了,因为它之前是预取的,并且通过自动调用layoutSubviews进行了布局 我猜原点没有在下一页的“旋转”或类似内容上更新 有人告诉我如何避免这个问题,而不是不使用景观吗?这是灵气中的一只虫子吗 编辑:我发现NIPagingScrollView提供了willRotateToInterfaceOrientation:duration:和willAnimateRotationInterfaceOrientation:duration:方法,视图控制器应该调用这些方法。我实现了这些调用,但仍然没有帮助。确实,NIPagingScrollView提供了这些方法,但是如果您查看它们,您会发现布局计算是基于scrollview帧值的 因此,如果您希望为分页滚动视图(例如,框架或主视图)指定正确的值,请在示例中将控制器视图更改为分页滚动视图\u scrollView 这样,就在动画之前,分页滚动视图将具有正确的等待帧,并且布局将被正确重新计算Iphone Nimbus NIPagingScrollView和旋转上的重新布局,iphone,ios,layout,autorotate,nimbus-ios,Iphone,Ios,Layout,Autorotate,Nimbus Ios,我正在使用NIPagingScrollView在iPhone上显示几个页面 每次我轻弹到一个页面,下一个页面也是预加载的,这很好 当我将iPhone从纵向模式旋转到横向模式时,我让LayoutSubView在我的NIPageView子类中进行重新布局。NIPagingScrollView设置为自动拉伸宽度和高度以保持全屏。这适用于当前页面 但是当我切换到下一页时,布局被破坏了,因为它之前是预取的,并且通过自动调用layoutSubviews进行了布局 我猜原点没有在下一页的“旋转”或类似内容上更
- (void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation
duration: (NSTimeInterval)duration {
// Your missing line of code to set the scroll view frame values
[self->_scrollView setFrame:self.view.bounds];
[self->_scrollView willAnimateRotationToInterfaceOrientation: toInterfaceOrientation
duration: duration];
[super willAnimateRotationToInterfaceOrientation: toInterfaceOrientation
duration: duration];
}
的确,NIPagingScrollView提供了这些方法,但是如果您查看它们,您将看到布局计算是基于scrollview帧值的
因此,如果您希望为分页滚动视图(例如,框架或主视图)指定正确的值,请在示例中将控制器视图更改为分页滚动视图\u scrollView
这样,就在动画之前,分页滚动视图将具有正确的等待帧,并且布局将被正确重新计算
- (void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation
duration: (NSTimeInterval)duration {
// Your missing line of code to set the scroll view frame values
[self->_scrollView setFrame:self.view.bounds];
[self->_scrollView willAnimateRotationToInterfaceOrientation: toInterfaceOrientation
duration: duration];
[super willAnimateRotationToInterfaceOrientation: toInterfaceOrientation
duration: duration];
}
谢谢你的提示,我将在下一次编写此代码时试用!谢谢你的提示,我将在下一次编写此代码时试用!