我的问题是,我的按钮和其他所有控件不工作时,我有添加scrollview编程到我的子视图。
override func viewDidLoad() {
super.viewDidLoad()
if(self.appDelegate.screenWidth < 568){
self.scrollView = UIScrollView(frame: view.bounds)
self.scrollView.delegate = self
self.scrollView.contentSize = CGSizeMake(self.appDelegate.screenWidth, 568)
scrollView.delaysContentTouches = false
scrollView.canCancelContentTouches = true
scrollView.scrollEnabled = true
// mainView consists all other controls like UIButton and other
scrollView.addSubview(mainView)
view.addSubview(scrollView)
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if(self.appDelegate.screenWidth < 568){
scrollView.frame = view.bounds
mainView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height)
}
}
有解决这个问题的建议吗??
Thanks in advance
我真的认为这是你的视图层次结构的问题。你将滚动视图添加到所有其他UI控件UIButton
等的顶部。所有的UI控件都应该是滚动视图的子视图,这样滚动和控件才能正常工作。