我这样做是为了将ViewController(viewController)移至其他ViewController(mainMenuViewController):
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "subView")
addChildViewController(controller)
view.addSubview(controller.view)
controller.view.frame.size.width = 375
controller.view.frame.size.height = 198
controller.didMove(toParentViewController: self)
viewController移至mainMenuViewController,但问题是我看不到其他诸如tableView,已添加到mainMenuViewController的按钮之类的项
答案 0 :(得分:0)
设置框架而不仅仅是高度
controller.view.frame = CGRect(x: xPosition, y: y, width: width, height: height)
还将autoreszingmaskToconstraint设置为false
controller.view.translatesAutoresizingMaskIntoConstraints = false;