以下代码在 iOS 16.0 的 Xcode-14.0.0-Beta 5 上运行时打破了布局约束
struct ContentView: View {
@State var date = Date()
var body: some View {
DatePicker(selection: $date, displayedComponents: .date, label: { EmptyView() })
.datePickerStyle(.graphical)
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议如何修复或隐藏警告吗?
控制台警告:
2022-08-24 17:16:40.471325+0300 DatePickerProblem[77364:483284] [LayoutConstraints] 无法同时满足约束。可能至少以下列表中的约束之一是您不想要的。尝试这样做:(1)查看每个约束并尝试找出您不期望的约束;(2) 找到添加了不需要的约束的代码并修复它。(注意:如果您看到不理解的 NSAutoresizingMaskLayoutConstraints,请参阅 UIView 属性的文档translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x600003559180 h=--& v=--& _UIDatePickerCalendarTimeView:0x7fe15c322520.height == 0 (活动)>", "<NSLayoutConstraint:0x60000352bca0 _UIDatePickerCompactTimeLabel:0x7fe15c322bc0.centerY == _UIDatePickerCalendarTimeView:0x7fe15c322520.centerY - 1 (活动)>", "<NSLayoutConstraint:0x60000352bcf0 V:|-(> =0)-[_UIDatePickerCompactTimeLabel:0x7fe15c322bc0 ] (active, names: '|':_UIDatePickerCalendarTimeView:0x7fe15c322520 )>" ) 将尝试通过破坏约束来恢复 <NSLayoutConstraint:0x60000352bca0 _UIDatePickerCompactTimeLabel:0x7fe15c322bc0.centerY == _UIDatePickerCalendarTimeView:0x7fe15c322 520.centerY - 1(活动)> 制作符号断点在 UIViewAlertForUnsatisfiableConstraints 中在调试器中捕获此内容。<UIKitCore/UIView.h> 中列出的 UIView …