我在 ScrollView 上加载 UIViewController 时遇到了一个小问题。
在我的应用程序中,我在底部使用了 4 个选项卡按钮。其中一个包含 ScrollView ,因为该 View 中的字段数量更多。其中一个字段用于接受用户的日期。
当我在 UIViewController 类上添加这个 Date Picker View(UIViewController) 时,加载 Date Picker View 没有问题,但是当我在 UIScrollView 上添加 Date Picker View 时出现问题。当我触摸日期选择器 View 上的任何按钮时,应用程序崩溃。
在 UIScrollView 上加载 UIViewController 有什么问题吗???。如果我想在 ScrollView 上接受日期表单用户,或者我如何在 ScrollView 上添加 UIViewController 以接受来自日期选择器的日期,还有什么选择。
提前致谢。 问候, 维沙尔。
最佳答案
试试看:
self.scrollView.frame = CGRect( <set frame> )
var vcView = UIView(frame: CGRect( <set frame> ))
addChildVC(vcView: vcView)
self.scrollView.addSubview(vcView)
self.scrollView.contentSize = CGSize( <set content size> )
添加 subview Controller
func addChildVC(vcView: UIView){
let testVC = self.storyboard?.instantiateViewControllerWithIdentifier("testIdentifier") as! TestViewController
testVC.view.frame = vcView.bounds
vcView.addSubview(testVC.view)
self.addChildViewController(testVC)
testVC.didMoveToParentViewController(self)
}
关于ios - 如何在 UIScrollView 上添加 UIViewController View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2107458/