正常放置我的 VC 会self.window?.rootViewController = UITableViewVC()
产生预期的结果。
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.darkGray
let nvc = UINavigationController(rootViewController: UITableViewVC())
self.window?.rootViewController = UITableViewVC()
当我将它包含在 aUINavigationController
中时,约束让我失望了。
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.darkGray
let nvc = UINavigationController(rootViewController: UITableViewVC())
self.window?.rootViewController = nvc
我不明白 UINVC 突然做了什么,我的 VC 无法正常显示。
这是我使用 SnapKit 设置它们的方法。
class UITableViewVC: UIViewController,
UITableViewDelegate,
UITableViewDataSource {
override func loadView() {
self.view.addSubview(tableView)
view.translatesAutoresizingMaskIntoConstraints = false
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.snp.remakeConstraints { [unowned self] (make: ConstraintMaker) in
make.topMargin.equalTo(self.view.bounds.size.height*0.35)
make.left.equalTo(view).offset(self.view.bounds.size.width*0.15)
make.right.equalTo(-self.view.bounds.size.width*0.15)
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom)
}
}