gpt4 book ai didi

ios - _UIButtonBarStackView : breaking constraint when becomeFirstResponder sent

转载 作者:IT王子 更新时间:2023-10-29 08:06:13 25 4
gpt4 key购买 nike

当从一个文本框跳到另一个文本框时,得到这个:

translatesAutoresizingMaskIntoConstraints) 
(
"<NSAutoresizingMaskLayoutConstraint:0x6040002806e0 UIKeyboardAssistantBar:0x7f986d40d020.height == 0>",
"<NSLayoutConstraint:0x60400008ece0 _UIButtonBarStackView:0x7f986d4041c0.top == UIKeyboardAssistantBar:0x7f986d40d020.top>",
"<NSLayoutConstraint:0x60400008ed30 UIKeyboardAssistantBar:0x7f986d40d020.bottom == _UIButtonBarStackView:0x7f986d4041c0.bottom>",
"<NSLayoutConstraint:0x60400009f220 _UIButtonBarButton:0x7f986d438480.height == UILayoutGuide:0x6040005b5ee0.height>",
"<NSLayoutConstraint:0x60400008e1a0 _UIButtonBarStackView:0x7f986d4041c0.bottom == UILayoutGuide:0x6040005b5ee0.bottom + 9>",
"<NSLayoutConstraint:0x60400008e100 UILayoutGuide:0x6040005b5ee0.top == _UIButtonBarStackView:0x7f986d4041c0.top + 10>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60400008e1a0 _UIButtonBarStackView:0x7f986d4041c0.bottom == UILayoutGuide:0x6040005b5ee0.bottom + 9>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

在模拟器中测试,不要进入设备。 shortcuts bar 有问题在键盘上 1

enter image description here

我 super 简单的代码触发了打破约束:

-(BOOL)textFieldShouldReturn:(UITextField*)textField
{
[textField resignFirstResponder];

if (textField.tag > 0) {

UITextField *nextTextField = [self.view viewWithTag:textField.tag+1];
[nextTextField becomeFirstResponder];
}

return YES;
}

最佳答案

这个警告让我烦恼了很长一段时间。我通过清空 UITextField 的 inputAssistantItem 属性上的 leadingBarButtonGroupstrailingBarButtonGroups 发现了一个两行的“hack”:

inputAssistantItem.leadingBarButtonGroups = []
inputAssistantItem.trailingBarButtonGroups = []

这控制调用时 UIKeyboardAssistantBar AutoLayout 警告

becomeFirstResonder()

更多信息在这里:https://developer.apple.com/documentation/uikit/uitextinputassistantitem

Apple 的特别说明:

To hide shortcuts altogether, set the leadingBarButtonGroups and trailingBarButtonGroups properties to nil.

关于ios - _UIButtonBarStackView : breaking constraint when becomeFirstResponder sent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46566188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com