Как исправить проблему безопасной области iOS10 и проблему с topLayoutGuide? - PullRequest
0 голосов
/ 11 января 2019

У меня вопрос по поводу безопасной зоны.
А я пишу код и встраиваю два симулятора iOS версии 10.2 и 11.4.
Он показывает другую часть области красного прямоугольника, как показано на следующем рисунке.
Что со мной не так?
Спасибо.

image

код здесь:

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = UINavigationController(rootViewController: ViewController())
        window?.makeKeyAndVisible()

        return true
    }
}

class ViewController: UIViewController {

    let tableView = UITableView()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "TITLE HERE"

        tableView.dataSource = self
        tableView.delegate = self

        self.view.addSubview(tableView)
        tableView.snp.makeConstraints { (make) in
            make.left.equalTo(10)
            make.top.equalTo(self.topLayoutGuide.snp.bottom)
            make.right.bottom.equalTo(-10)
        }

    }

}

extension ViewController: UITableViewDelegate, UITableViewDataSource {

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 20
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = UITableViewCell()
        cell.textLabel?.text = "\(indexPath) TEST"

        return cell
    }

}
...