远程键盘的UIViewAlertForUnsatisfiableConstraints警告

时间:2019-02-16 22:58:50

标签: ios swift xcode

只要满足以下条件,我就会在Xcode中收到UIViewAlertForUnsatisfiableConstraints警告:

  1. 具有2个文本字段的AlertController(从第一个文本字段移至第二个文本字段时会发出警告)
  2. iPad(不是iPhone)
  3. 使用外部键盘(模拟器或物理设备)。使用软件键盘不会发生该错误。

为了尝试确定问题,我创建了一个带有两个标签的测试项目,一个标签按钮(“ add”)和一个调用Alertcontroller的addTapped函数。这是警报控制器逻辑:

    @objc func addTapped() {
    let alert = UIAlertController(title: "Please enter", message: "", preferredStyle: .alert)

    var textField = UITextField()
    var textField2 = UITextField()

    alert.addTextField { (alertTextField1) in
        alertTextField1.placeholder = "Your full name"
        textField = alertTextField1
    }
    alert.addTextField { (alertTextField2) in
        alertTextField2.placeholder = "Your email address"
        textField2 = alertTextField2
    }

    let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertAction.Style.default, handler: nil)

    let action = UIAlertAction(title: "Add", style: .default) { (action) in
        self.fullNameLabel.text = textField.text
        self.emailAddressLabel.text = textField2.text
    }

    alert.addAction(action)
    alert.addAction(cancelAction)
    alert.preferredAction = action
    present(alert, animated: true, completion: nil)
}

我阅读了这两篇SO文章中的答案,并遵循了有关创建断点的建议。 how to trap unsatifiable constraints unsatisfiable constraints in pop over

从断点开始,Xcode将此约束确定为模拟器中的问题:

debug snippet1

遵循本文的建议:

Medium article on unsatisfiable constraints

我跑了(lldb)po $ rbx

返回:

<UIRemoteKeyboardWindow: 0x7fe66e820a00; frame = (0 0; 768 1024); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x600002450c40>>

远程键盘窗口上的约束不正确?

当我在物理iPad上运行测试程序时,它在此处停止:

debug snippet2

(lldb)po $ rbx在这种情况下不起作用,因此我无法查看它是否也正在识别“远程键盘窗口”的问题

我的主要问题是:如何摆脱这一警告?此外,如果我没有办法摆脱此警告,是否有可能在应用审核过程中引起问题?

0 个答案:

没有答案