自动布局presenting视图控制器(很多情况下)后失效 [英] Auto layout invalid after presenting view controller (and many situation)

查看:166
本文介绍了自动布局presenting视图控制器(很多情况下)后失效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义容器控制器,它就像的UITabBarController,但与开关动画。我使用自动布局来实现。结果
由于子控制器之间的切换是动态的,适当的约束添加到子视图控制器时,它的观点加入到容器中的观点,而不是pre-设置在IB。 (该约束添加到过程的上海华)

I have a custom container controller, which just like UITabBarController, but with switch animation. And I use auto layout to achieve.
Because switch between child controllers is dynamic, the proper constraints are added to child view controller when its's view is added into container's view, not pre-setup in IB. (The constraints are added to the superview of course)

http://d.pr/i/q6NF 集装箱控制器NIB设置

http://d.pr/i/q6NF Container Controller Nib Setup

PS:
约束的详细结果,
H:| [儿童](更改约束的常数左/右左/右动画)结果
H:[儿童(==超)]结果
五:| [儿童] |

PS: The detail of constraints
H:|[Child](Change the constraint's constant to animation from left/right to right/left)
H:[Child(==Super)]
V:|[Child]|

一个孩子控制器是一个导航控制器,出问题时,导航控制器present一个模态视图控制器(使用 presentViewController:动画:完成:),并使用驳回( dismissViewControllerAnimated:完成:),之后present /解雇导航控制器成为帧(X,Y,0,0) 这似乎是自动布局变得无效,可能限制被删除。

One of the child controller is a navigation controller, things go wrong when the navigation controller present a modal view controller (using presentViewController:animated:completion:), and dismiss it(usingdismissViewControllerAnimated:completion:), after present/ dismiss the frame of navigation controller become (x, y, 0, 0), It seems like the auto layout becomes invalid, maybe the constraints been removed.

http://d.pr/i/VmvL 的present /辞退处理

http://d.pr/i/VmvL The Present/ Dismiss Process

我没有使用code核实发生什么这些限制没有,但随着星火督察我看到了present期间的看法presentation变化/解雇的过程。当我的导航控制器present一个模态视图控制器,只是iOS版的交换整个导航控制器的视图模态视图控制器的看法。当导航控制器的视图回来,自动布局不工作了。

I haven't use code to verify what happen to these constraints yet, but with Spark Inspector I see the views presentation change during the present/ dismiss process. When My navigation controller present a modal view controller, iOS just swap the whole navigation controller's view to the modal view controller's view. And when navigation controller's view come back, the auto layout doesn't work anymore.

一,我想出了是让我的容器控制器present模态控制器的解决方案。

One of the solution I came up with is let my container controller present modal controller.

或者我只是改变我的容器控制器没有自动布局。

Or I just change my container controller to no auto layout.

事实上,自从我开始使用自动布局,这种技术使刚刚称霸利益的问题。 除了这个问题,每次界面方向的变化,我的容器控制器内部的观点就是不能自动排版正确的,它似乎总是子视图方向改变之前使用的SuperView的框架。我仔细检查了我的限制设置,没有冲突,没有歧义。

The fact is ever since I start using auto layout, the problems this technique causes just dominate the benefits. Besides this problem, Every time the interface orientation changes, views inside my container controller just can't auto layout right, it seems subviews always use the frame of superview before orientation change. I double check the constraints I setup, there is no conflicts and no ambiguity.

我的猜测是我的自定义容器控制器与presenting模式视图控制器和自动布局系统接口方向改变兼容,即使限制设置。

My guess is that my custom container controller isn't compatible with presenting modal view controller and interface orientation change in Auto Layout system, even with constraints setup.

X code 5测试版,iOS版7SDK,目标iOS6.1 或许真的不正确的SDK环境?

Xcode 5 beta, iOS 7SDK, target iOS6.1 Maybe Something not right with the SDK environment?

这是我的第一个问题,所以我没有足够的信誉发表图片,但我提供的截图链接。很抱歉的!

This is my first question, so I don't have enough reputation to post images, but I provide links for the screenshots. Sorry for that!

推荐答案

我有一个类似的问题。我设置 translatesAutoresizingMaskIntoConstraints = NO; 我的根的UIView。
它显示外层的UIView - SuperView把你的等级必须使用默认的 translatesAutoresizingMaskIntoConstraints = YES 的根。
一旦我删除这一点,一切都如预期。

I had a similar problem. I was setting translatesAutoresizingMaskIntoConstraints = NO; on my root UIView. It appears the "outermost" UIView - the superview at the root of your hierarchy must use the default translatesAutoresizingMaskIntoConstraints = YES. Once I've removed this, everything worked as expected.

这篇关于自动布局presenting视图控制器(很多情况下)后失效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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