在dismissViewControllerAnimated:completion 后视图不可用: [英] View unusable after dismissViewControllerAnimated:completion:

查看:24
本文介绍了在dismissViewControllerAnimated:completion 后视图不可用:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在迁移使用 NIB 的旧代码以使用手动视图创建 (loadView) 和自动布局.根视图控制器是一个容器 VC(有 2 个子项),它使用自动布局并以模态呈现一个视图控制器,该视图控制器的布局在 NIB 中指定,但尚未使用自动布局.presentViewController:animated:completion: 之后一切都很好,但是当模态视图通过委托调用 dismissViewControllerAnimated:completion: 关闭时,呈现的视图会变得奇怪,不可用状态,内容奇怪地移动并且对触摸没有反应.

I'm migrating older code that used NIBs to use manual view creation (loadView) and Auto Layout. The root view controller is a container VC (with 2 children) that uses auto layout and modally presents a view controller that has its layout specified in a NIB and does not yet use auto layout. All is fine after presentViewController:animated:completion:, but when the modal view is closed with dismissViewControllerAnimated:completion: via delegate call, the presenting view is left in a strange, unusable state where the content is weirdly shifted and does not react to touch.

我尝试创建最少的测试用例来重现该问题,但未能重现该问题.

I have tried to create minimal test case to reproduce the problem, but I've failed to reproduce the issue.

这可能是什么原因造成的?

What could be causing this?

推荐答案

我在我的根 UIView 上设置了 translatesAutoresizingMaskIntoConstraints = NO;.它出现在最外层"UIView — 视图层次结构根部的超级视图必须使用默认的 translatesAutoresizingMaskIntoConstraints = YES.一旦我删除了它,一切都按预期工作.

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

这篇关于在dismissViewControllerAnimated:completion 后视图不可用:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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