我的问题是在更新UITableView子项中的数据后,将UIView的高度从40pt(情节提要中提到的高度)增加到大约(1400)。该视图没有在增加的区域中获取事件。它仅接收低于原始高度的触摸事件。
查看Xib文件中的继承关系
ScrolView
- UIView(1)
-- UIView (1.1)
-- UIView (1.2) (commentView) (width superview.width, height - 40)
---UITableView (1.2.1) (commentTableView) (not in xib)
我的代码是-
override func viewDidLoad() {
super.viewDidLoad()
commentView = view.viewWithTag(999)
// adding tableview inside comment view
if commentView != nil {
commentTableView = UITableView(frame: CGRectMake(0, 0, commentView.frame.width, commentView.frame.height))
commentView!.addSubview(commentController!)
}
}
// After adding rows to table, update size of table
func afterSettingTableContent() {
log.info("bound before change\(commentView?.bounds)")
commentView?.frame.size.height = (commentTableView?.contentSize.height)!
commentTableView.frame.size.height = (commentView?.frame.height)!
scrollView.contentSize.height += (commentView?.frame.size.height)!
}
问题是commentView的超级视图的高度即UIView(1)是固定的。由于clipToBounds为假,因此子视图呈现良好,并且由于其大小仍为40,因此它们没有受到任何触摸。增加视图高度1后,一切正常。(Silly Mistake)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句