Nimbus NIPagingScrollView 和旋转重新布局
我正在使用 NIPagingScrollView
在 iPhone 上显示多个页面。
每次我翻到一页时,也会预先加载下一页,这很好。
当我将 iPhone 从纵向模式旋转为横向模式时,我让 layoutSubviews
在我的 NIPageView
子类中进行重新布局。 NIPagingScrollView
设置为自动拉伸宽度和高度以保持全屏。这适用于当前页面。
但是当我翻到下一页时,布局被破坏了,因为它是之前预取的,并且也是通过自动调用layoutSubviews
来布局的。
我猜原点没有更新就在下一页上旋转,或者类似的东西。
有人提示我如何避免这个问题(除了不使用景观)?这是 Nimbus 中的一个错误吗?
编辑:我发现NIPagingScrollView
提供了应该调用的方法willRotateToInterfaceOrientation:duration:
和willAnimateRotationToInterfaceOrientation:duration:
由视图控制器。我实现了这些调用,但仍然没有帮助。
I'm using an NIPagingScrollView
to display several pages on the iPhone.
Everytime I flick to a page, the next page is also pre-loaded, which is fine.
When I rotate the iPhone from Portrait to Landscape mode, I let layoutSubviews
do the re-layouting in my subclass of NIPageView
. The NIPagingScrollView
is set to auto-stretch in width and height to stay fullscreen. This works for the current page.
But when I flick to the next page, the layout is broken, as it was prefetched before and also layouted by an automatic call to layoutSubviews
.
I guess the origin is not updated right on the next page on rotation, or something like that.
Has someone a hint on how I can avoid this problem (other than not using Landscape)? And is this a bug in Nimbus?
EDIT: I discovered that NIPagingScrollView
provides the methods willRotateToInterfaceOrientation:duration:
and willAnimateRotationToInterfaceOrientation:duration:
which should be called by the view controller. I implemented these calls, but it still does not help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,NIPagingScrollView 提供了这些方法,但是如果您查看它们,您会发现布局计算是基于滚动视图框架值的。
因此,如果您希望为分页滚动视图赋予正确的值,例如,将框架或主视图(控制器视图)赋予分页滚动视图(示例中的_scrollView)。
这样,就在动画之前,您的分页滚动视图将具有正确的等待帧,并且您的布局将被正确重新计算。
Indeed
NIPagingScrollView
provides those methods, but if you look at them, you'll see that the layout computations are based on the scrollview frame values.So if you want the correct values to be given to your paging scroll view, just for example, the frame or your main view (the controller view) to the paging scroll view (_scrollView in the example).
That way, just before the animation, your paging scroll view will have the correct waited frame, and your layout will be recomputed correctly.