【发布时间】:2017-05-02 08:17:11
【问题描述】:
我有一个UITableViewCell,我在其中添加了我的自定义视图,比如说
class MyView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
convenience required init(size: CGFloat) {
self.init(frame: CGRect.zero)
height = size
// init my other sub contents [1]
}
}
来自我的UITableViewCell:
let myView = MyView(size: 35)
contentView.addSubView(myView)
我的问题:我在 MyView 中的其他 UI 组件依赖于 MyView 的 width 和 height,现在设置它们在 [1] 中的位置还为时过早,因为 MyView 的框架现在是 @ 987654331@
我应该将我的其他 UI 组件放在 MyView 的什么位置? UIView 中是否有代表告诉我:“嘿,视图的框架已更新为其实际大小。”? (如viewDidAppear 中的UIViewController)
问候,
【问题讨论】: