Placing my VC normally as self.window?.rootViewController = UITableViewVC()
produces the expected result.
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.darkGray
let nvc = UINavigationController(rootViewController: UITableViewVC())
self.window?.rootViewController = UITableViewVC()
The moment I contain it inside a UINavigationController
, the constraints fail me.
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.darkGray
let nvc = UINavigationController(rootViewController: UITableViewVC())
self.window?.rootViewController = nvc
I don't understand what the UINVC did all of a sudden that my VC doesn't display properly.
Here is how I set them up with 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)
}
}