我正在使用 subview Controller 在我的场景中呈现各种状态。我有:每个状态的 LoadingViewController、FailureViewController 和 TableViewController。
extension UIViewController {
func add(_ child: UIViewController) {
addChild(child)
view.addSubview(child.view)
child.didMove(toParent: self)
}
func remove() {
guard parent != nil else {
return
}
willMove(toParent: nil)
removeFromParent()
view.removeFromSuperview()
}
}
我的问题是,子 Controller View 在 iPhone X 上不完全适合父 View (其他设备也很好)。谢谢
最佳答案
为什么不尝试向 subview 添加显式框架,即
func add(_ child: UIViewController) {
addChild(child)
child.view.frame = (your expected frame)
view.addSubview(child.view)
child.didMove(toParent: self)
}
关于ios - subview Controller View 不适合 parent 在 iPhone X 上的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52835010/