当关闭模态视图控制器时,底层 UIScrollView 调整大小为全屏
我有一个布局,顶部有一个自定义状态栏[在Apple的状态栏下方],然后是一个在中间部分从左到右分页的UIScrollview
,然后我有一个UIView
底部有一些自定义按钮。一个简单的三窗格布局,效果很好。但是,下部视图上的三个自定义按钮会弹出一个 ModalViewController
,当它被关闭时,它会将中间的 UIScrollView
调整为全屏,并将其带到前面,涵盖了我的另外两个观点。
还有其他几个人注意到了这种行为,但似乎他们给出的唯一答案是将 UIScrollView 的大小重新调整回原始坐标。当然,这会起作用,但对我来说这似乎是一种黑客行为,我想知道这里幕后到底发生了什么,以及如何正确纠正问题。
其他具有相同明显问题的 SO 链接:
- 忽略 UIScrollView 底层的模式视图更改
- < a href="https://stackoverflow.com/questions/5747566/dismissing-modal-view-controller-causing-layout-problems">解除模态视图控制器导致布局问题
- 关闭模态视图控制器时的奇怪行为
仍然其他人指出该行为仅影响 3.0 及更高版本,因此我不确定这是否是一个“功能”,而且我只是不明白该行为应该做什么或做什么。如果有人能对此有所了解,我将不胜感激。
I have a layout with a custom status bar on top [below Apple's status bar], then a UIScrollview
that paginates left to right in the middle section, and then I have a UIView
with some custom buttons on the bottom. So a simple three-paned layout, and it works great. However, the three custom buttons on the lower view bring up a ModalViewController
, and when that is dismissed, it resizes the middle UIScrollView
to full-screen, and brings it to the front, covering the other two views that I have.
There are several others who have noted this behavior, but it seems that the only answers they are given is to re-resize the UIScrollView
back to the original coordinates. This will work, of course, but it seems like a hack to me, and I would like ot know what is really going on behind the scenes here, and how to rectify the issue correctly.
Other SO links with the same apparent issue:
- Dismiss modal view changes underlying UIScrollView
- Dismissing Modal View Controller causing layout problems
- Weird Behavior on dismissing Modal View Controller
Still others have noted that the behavior only affects 3.0 and up, so I am not sure if this is a "feature," and I am just not understanding what the behavior is supposed to be doing, or what. If anyone can shed some light on this, I would be grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有完全相同的问题。
在模式视图的父级中,我使用这个
: OriginalHeight 是我的父视图的原始尺寸。
它工作得很好,即使这对我来说也像是一个黑客。
I have exactly the same problem.
In the parent of the modal view, I'm using this:
where originalWidth & originalHeight are the original sizes of my parent view.
it works fine, even if it sounds like a hack to me too.
您是否尝试过更改 nib 文件中的设置?
检查笔尖中滚动视图的自动调整大小。
Have you tried to change setting in nib files.?
Check the autosizing of scroll view in nib.