选择 UITextField 时出现 Swift 键盘错误

问题描述

我创建了一个常规的 UITextFiled,如下所示:

self.view.addSubview(userName)
userName.translatesAutoresizingMaskIntoConstraints = false
userName.topAnchor.constraint(equalTo: nameLabel.topAnchor).isActive = true
userName.leadingAnchor.constraint(equalTo: nameLabel.trailingAnchor).isActive = true
userName.heightAnchor.constraint(equalTo: nameLabel.heightAnchor,constant: 0).isActive = true
userName.widthAnchor.constraint(equalTo: view.widthAnchor,multiplier: 0.5).isActive = true 
userName.textColor = .black

选择 UITextFiled 时,键盘按预期显示,但出现以下错误。我做了什么?这只是一个简单的 UITextField。究竟是什么问题?

2021-01-16 19:29:50.826058-0600 AIP[15001:6410326] [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. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand,refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x281c8a170 h=--& v=--& _UIbuttonbarButton:0x133059600.height == 0   (active)>","<NSLayoutConstraint:0x281c89630 _UIUCBKBSelectionBackground:0x133059f20.bottom == _UIbuttonbarButton:0x133059600.bottom - 6   (active)>","<NSLayoutConstraint:0x281c89590 V:|-(6)-[_UIUCBKBSelectionBackground:0x133059f20]   (active,names: '|':_UIbuttonbarButton:0x133059600 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x281c89630 _UIUCBKBSelectionBackground:0x133059f20.bottom == _UIbuttonbarButton:0x133059600.bottom - 6   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-01-16 19:29:50.826729-0600 AIP[15001:6410326] [LayoutConstraints] Unable to simultaneously satisfy constraints.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)