我有垂直scrollView,其contentSize高度大于窗口高度。但它不会滚动。如果我设置scrollView.contentSize.height = 2000
当我添加childviewcontroller时,在viewWillAppear上计算scrollView的高度。
代码正在关注
self.parentView.addSubview(gameInfoMainViewController!.view)
gameInfoMainViewController!.view.frame = self.parentView.bounds
gameInfoMainViewController!.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
gameInfoMainViewController!.view.frame.size.height = gameInfoMainViewControllerHeight!
在添加子视图的行上,正在调用委托方法
func passGameInfoTeamsViewControllerHeight(height:CGFloat) {
gameInfoTeamsViewControllerHeight = height
parentView.frame.size.height = gameInfoTeamsViewControllerHeight!
parentView.layoutIfNeeded()
scrollView.contentSize.height = gameInfoTeamsViewControllerHeight! + segmentedControll!.frame.height + headerView.frame.size.height + 64
}
最奇怪的是,如果我再次调用此代码,滚动工作
self.parentView.addSubview(gameInfoMainViewController!.view)
gameInfoMainViewController!.view.frame = self.parentView.bounds
gameInfoMainViewController!.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
gameInfoMainViewController!.view.frame.size.height = gameInfoMainViewControllerHeight!
有什么想法吗?