【发布时间】:2018-01-04 10:39:24
【问题描述】:
我尝试遵循1 和2 中的一些指南,但是当我尝试在情节提要中呈现自定义视图时出现错误。
无法渲染和更新视图控制器的自动布局状态。代理抛出异常。
这是我迄今为止尝试过的:
@IBDesignable final class CustomView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
private func setup() {
let customViewNib = loadFromNib()
customViewNib.frame = bounds
customViewNib.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
addSubview(customViewNib)
}
func loadFromNib() -> UIView {
let nib = UINib(nibName: "CustomView", bundle: Bundle.main)
let view = nib.instantiate(withOwner: self, options: nil).first as! UIView
return view
}
}
我已经设置了我的自定义视图的文件所有者。
我已经创建了一个新的空项目来解决这个问题:
https://github.com/ivangodfather/CustomView
或
【问题讨论】:
-
请将该 ufile 链接后面的任何内容上传到此站点。将代码或图像放在这里。
-
很遗憾我不能在这里上传我的项目
标签: ios swift ibdesignable