错误场景
在Form->Section中使用了NavigationLink
NavigationLink {
List{
Picker("",selection: $stopRepeatOptionNumber){
ForEach(0 ..< stopRepeatOpion.count, id: \.self){index in
Text("\(self.stopRepeatOpion[index])")
}
if (stopRepeatOptionNumber == 1) {
DatePicker("日期选择",selection: $stopRepeatDate,displayedComponents: [.date])
.datePickerStyle(GraphicalDatePickerStyle())
.animation(.easeInOut)
.environment(\.locale, Locale(identifier: "zh_CN"))
}
}.pickerStyle(.inline)
}
} label: {
HStack{
HStack{
Image(systemName:"stop.circle")
.resizable()
.frame(width: 22.0, height: 22.0)
.padding(.trailing,3)
.foregroundColor(Color.red)
Text("结束重复")
}
Spacer()
Text(stopRepeatOptionNumber == 0 ? "永不" : getFormatedDate(date: dueDate, onlyDate: true))
}
}.navigationViewStyle(.stack)
错误提示
2023-02-26 18:57:31.691868+0800 xxxxxx[64781:19341014] [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:0x6000003c7f20 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x7fdb394d4fb0.bottom == _UIKBCompatInputView:0x7fdb39722b80.top (active)>",
"<NSLayoutConstraint:0x600000028280 'assistantHeight' SystemInputAssistantView.height == 45 (active, names: SystemInputAssistantView:0x7fdb3962e690 )>",
"<NSLayoutConstraint:0x6000003c6210 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x7fdb39722b80.top (active, names: SystemInputAssistantView:0x7fdb3962e690 )>",
"<NSLayoutConstraint:0x6000003c61c0 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x7fdb394d4fb0]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x7fdb3962e690 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000003c61c0 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x7fdb394d4fb0]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x7fdb3962e690 )>
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.
解决办法
虽然这个提示没有对功能造成任何影响,我也没找出具体是什么原因,但是有人说加一行下面代码就能解决,确实如此。
.navigationViewStyle(.stack)