【已解决】[LayoutConstraints] Unable to simultaneously satisfy constraints.【SwiftUI错误】

错误场景

在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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值