I'm on Xcode 10.1 and the simulator is version 10.1 also but it happened with the previous version from last year too. I didn't bother with it because I was building out the basic ui and backend so i skipped it. Now I'm almost ready to launch and now I need to test on the X series.
Whenever I use any of the other regular simulator iPhones from the 5S - 8+ there are no problems, everything is fine, I touch a button and the action happens. I have an iPhone 7+ and the buttons work fine using the actual device.
But whenever I use the simulator and I choose any of the iPhone X series devices when I touch any button in any view controller I always get a crash
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIBackButtonContainerView titleLabel]: unrecognized selector sent to instance 0x7fdd99c759e0'
whatever this is causes the problem in the X series [_UIBackButtonContainerView titleLabel]
I'm running Xcode in Debug Mode:
What could be the problem?
Code-
lazy var loginButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("Login", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.titleLabel?.font = UIFont(name: "ArialRoundedMTBold", size: 19)
// I also tried commenting out button.titleLabel?.font = UIFont(name: "ArialRoundedMTBold", size: 19)
button.backgroundColor = UIColor.lightGray
button.addTarget(self, action: #selector(loginButtonPressed), for: .touchUpInside)
button.clipsToBounds = true
button.layer.cornerRadius = 5
}()
@objc func loginButtonPressed() {
// do something
}
override func viewDidLoad() {
super.viewDidLoad()
// there is a username textfield and a password textField above the button
view.addSubview(loginButton)
loginButton.topAnchor.constraint(equalTo: passwordTextField.bottomAnchor, constant: 8).isActive = true
loginButton.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16).isActive = true
loginButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16).isActive = true
if UIScreen.main.bounds.width == 320 {
loginButton.heightAnchor.constraint(equalToConstant: 40).isActive = true
} else {
loginButton.heightAnchor.constraint(equalToConstant: 45).isActive = true
}
}
Here is a picture of the button with just a print statement in the action:
Here is a picture of the crash:




