我在日期选择器视图顶部有一个自定义按钮。当日期选择器处于活动状态时,我得到“无法同时满足约束”。在我更新到 Xcode 11 后,错误出现了,
这是我的代码:
let toolbar = UIToolbar()
let flexBarButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let done = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(viewTapped))
toolbar.sizeToFit()
toolbar.setItems([flexBarButton,done], animated: false)
dateInputTextField.inputAccessoryView = toolbar
Run Code Online (Sandbox Code Playgroud)
这是错误:
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 …Run Code Online (Sandbox Code Playgroud)