解雇ModalViewController后,UIScrollView的内容发生了移动 [英] Contents of UIScrollView shifted after dismissing ModalViewController

查看:94
本文介绍了解雇ModalViewController后,UIScrollView的内容发生了移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分页滚动视图。每个页面都有一个viewcontroller(buttonViewController),用于管理按钮网格。如果你按下其中一个按钮,buttonViewController会以模态方式弹出另一个viewcontroller(detailViewController)。

I have a paged scrollview. Each page has a viewcontroller (buttonViewController) that manages a grid of buttons. If you press one of the buttons, the buttonViewController pops up another viewcontroller (detailViewController) modally.

问题是,当我关闭模态视图控制器时,可见的buttonViewController是向下移动了大约20像素。奇怪的是只有可见页面被移动了。如果我滚动到另一个已经加载的页面,它仍然处于正确的位置。

The problem is, when I dismiss the modal view controller, the visible buttonViewController is shifted down by what looks like about 20 pixels. The weird thing is that only the visible page is shifted. If I scroll over to another page that is already loaded, it is still in the correct position.

我的问题基本上与发送modalViewController移动iphone周围的主视图按钮

但是,该问题的接受答案假定状态栏已隐藏。我没有在我的申请中隐藏状态栏。

However, the accepted answer to that question assumed that the status bar is hidden. I am not hiding the status bar in my application.

还有其他想法吗?

还有一个注意事项:换档仅在我第一次启动模态视图控制器时发生。如果我继续打开和关闭模态视图控制器,一切都保持不变。

One more note: The shift only happens the first time I launch a modal view controller. If I keep opening and closing the modal view controller, everything stays the same.

还有一点需要注意:如果我添加以下代码:

One further note: if I add the following code:

    CGRect frame = self.view.frame;
frame.origin.y=0;
self.view.frame = frame;

然后我可以解决这个问题。帧似乎在y中移动了20像素。我仍然不知道是什么导致了这一举动。

after I dismiss the modal view controller, then I can work around the problem. The frame seems to move by 20pixels in y. I still don't know what's causing the move though.

推荐答案

原来这与以下内容有关:
滚动分页滚动视图时动画期间不显示ModalViewController

Turns out this was related to: ModalViewController doesn't display during animation when paged scrollView is scrolled

我的一些视图控制器的高度不匹配,这让一切都失去了。

I had mismatched the heights of some of my viewcontrollers, and that was throwing everything off.

有些视图的高度为460像素,有些视角为480像素。出于某种原因,这使它在20转瞬间移动了一个模态视图控制器消失了。一旦我制作了460像素,一切都很好。

Some of the views had heights of 460pixels, some had 480pixels. For some reason, this made it shift by 20pixels evertime a modal view controller disappeared. Once I made everything 460pixels, everything worked great.

这篇关于解雇ModalViewController后,UIScrollView的内容发生了移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆