[英]Nimbus NIPagingScrollView and Re-Layouting on Rotation
我正在使用NIPagingScrollView
在iPhone上显示多个页面。
每当我滑动到一页时,也会预加载下一页,这很好。
当我将 iPhone从纵向模式旋转到横向模式时,我可以使用layoutSubviews
在NIPageView
子类中进行重新布局。 NIPagingScrollView
设置为在宽度和高度上自动拉伸以保持全屏显示。 这适用于当前页面。
但是,当我轻拂到下一页时,布局被破坏了,因为它是之前被预取的,并且还通过自动调用layoutSubviews
进行布局。
我猜原点不会在旋转的下一页上更新,或者类似的东西。
有没有人暗示过我如何避免这个问题(除了不使用“风景”之外)? 这是Nimbus中的错误吗?
编辑:我发现NIPagingScrollView
提供了方法willRotateToInterfaceOrientation:duration:
和willAnimateRotationToInterfaceOrientation:duration:
应当由视图控制器调用。 我实现了这些调用,但仍然无济于事。
NIPagingScrollView
确实提供了这些方法,但是如果您看一下它们,就会发现布局计算是基于scrollview帧值的。
因此,如果希望将正确的值提供给页面滚动视图,例如,将框架或主视图(控制器视图)赋予页面滚动视图(本例中为_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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.