我正在为我的UIView
视图添加自定义HomeViewController
,如下所示:
var customView: CustomView!
func addCustomView() {
customView = CustomView(frame: CGRect(x: 0, y: 0, width: Int(view.frame.width), height: 150.0))
customView.translatesAutoresizingMaskIntoConstraints = false
customView.delegate = self
view.addSubview(customView)
self.view.addConstraint(NSLayoutConstraint(item: customView, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterY, multiplier: 1.0, constant: 0.0));
self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-20-[view]-20-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["view": customView]));
}
此自定义视图有一个按钮,该按钮可以分割为模态视图控制器,并将当前视图控制器设置为其委托。当我关闭模态视图控制器时,它调用其委托方法:
func modalVCDidCreateThing(thing: PFObject) {
customView.removeFromSuperview()
}
customView
未从超级视图中删除。
nil
removeFromSuperview
后,退出对象会显示它仍然存在hidden
属性设置为false,但视图不会隐藏。注销视图显示该属性已设置。view.setNeedsLayout
之后尝试removeFromSuperview
。没用。非常沮丧。感谢。