也许有人在 iOS 16 上发现了同样的错误
iOS 16 上推新屏幕并尝试向后滑动时会出现奇怪的键盘问题。当您从推送屏幕返回时,键盘安全区域不会更新。
这里的例子https://media.giphy.com/media/UaNesUynQ4O9fFBUUG/giphy.gif
var body: some View {
NavigationView {
ZStack {
VStack {
ScrollView {
ForEach(0..<40) { _ in
Color.red.frame(height: 30)
}
}
NavigationLink {
TextField("Text", text: .constant(""))
} label: {
Text("Press me")
}
}
}
}
.navigationViewStyle(.stack)
}
从 XCode 14.1 开始,我在日志中遇到错误
2022-11-02 10:33:00.540667+0200 SomeSUITestProj[22423:5008601] [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:0x283177f70 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x151210eb0.bottom == _UIKBCompatInputView:0x15120d500.top (active)>",
"<NSLayoutConstraint:0x28310cd20 'assistantHeight' SystemInputAssistantView.height == 45 (active, names: SystemInputAssistantView:0x15120b840 )>",
"<NSLayoutConstraint:0x283120a50 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x15120d500.top (active, names: SystemInputAssistantView:0x15120b840 )>",
"<NSLayoutConstraint:0x2831219f0 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x151210eb0]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x15120b840 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x2831219f0 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x151210eb0]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x15120b840 )>
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.
要解决此问题,您需要禁用文本字段的更正:
FloatingLabelTextField(title: "My field", text: $myFieldValue)
.disableAutocorrection(true)
来源:https://github.com/hackiftekhar/IQKeyboardManager/issues/1616#issuecomment-566500228