UIAlertController actionSheet выдает ошибку ограничения на iOS 12.2/12.3 - программирование
Подтвердить что ты не робот

UIAlertController actionSheet выдает ошибку ограничения на iOS 12.2/12.3

На iOS 12.2. при использовании UIAlertController actionSheet Xcode выдает ошибку ограничения любому, у кого возникла эта проблема

Этот же код работает на iOS 12.1 без ошибок

Я проверил этот код на Xcode 10.2 и 10.1

class ViewController: UIViewController {

    let Click : UIButton = {
        let button = UIButton(type: UIButton.ButtonType.system)
        button.translatesAutoresizingMaskIntoConstraints = false
        button.setTitle("OK", for: .normal)
        button.tintColor = UIColor.blue
        button.addTarget(self, action: #selector(click(_:)), for: UIControl.Event.touchUpInside)
        return button
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(Click)
        Click.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
        Click.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    }


    @objc func click(_ sender: UIButton) {
        let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .actionSheet)

        let deleteAction = UIAlertAction(title: "Delete", style: .default)
        let saveAction = UIAlertAction(title: "Save", style: .default)

        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)

        optionMenu.addAction(deleteAction)
        optionMenu.addAction(saveAction)
        optionMenu.addAction(cancelAction)

        self.present(optionMenu, animated: true, completion: nil)
    }

}
[LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x6000001b6ee0 UIView:0x7fe3b6513020.width == - 16   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000001b6ee0 UIView:0x7fe3b6513020.width == - 16   (active)>

PS:

Просто чтобы убедиться, что проблема в UIAlertController я UIAlertController все и обновляю код, как UIAlertController ниже, но та же ошибка.

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        let optionMenu = UIAlertController(title: "Test", message: "Choose Option", preferredStyle: .actionSheet)

        let deleteAction = UIAlertAction(title: "Delete", style: .default)
        let saveAction = UIAlertAction(title: "Save", style: .default)

        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)

        optionMenu.addAction(deleteAction)
        optionMenu.addAction(saveAction)
        optionMenu.addAction(cancelAction)

        self.present(optionMenu, animated: true, completion: nil)
    }

}
4b9b3361

Ответ 1

Это новая ошибка в версиях iOS:

  • 12.2
  • 12.3
  • 12.4
  • 13.0

Единственное, что мы можем сделать, это отправить отчет об ошибке в Apple (только что сделал).

Я постараюсь обновить ответ для новой версии (версий) iOS, когда она выйдет.

Ответ 2

Подтверждено. Та же проблема, xcode 10.2.1, iOS 12.2, цель 11.0.