0
这里是我的应用程序,左侧的配置文件(ProfileViewController)和右侧的容器视图(ContainerViewController)。我试图实现的是一旦containerViewController完成了它的工作,它将更新UIView的高度。修改容器视图的高度
// ContainerViewController.swift
let heightConstraint = self.view.constraints.filter { $0.identifier == "Height" }.first
heightConstraint?.constant = height
当浏览限制的名单,他们都是emtpy,我也设立在故事板的一些限制。所以为什么 ?有什么方法可以访问ContainerViewController中的UIView?
PS:
DispatchQueue.main.async {
self.view.frame = CGRect(x: 0, y: 0, width: width, height: height)
}
听起来工作,但我认为,修改约束是正确的?不 ?
我无法为containerViewController中的约束设置IBOutlet,它只能在ProfileViewController中链接它时才起作用。这意味着使用协议和containerViewController将更新baseController(ProfileViewController)。是否有任何其他方式让所有的控制器独立,并确实将IBoulet链接到containerViewController? – Alex
如果你在containerViewController中有约束,它应该可以工作,但是如果你在ProfileViewController中约束并且只是“调节”containerViewController。 (看故事板树)。在初始化视图后,您可以将ProfileViewController的约束传递给containerViewController –