Maybe someone found the same bug on iOS 16
There's a strange keyboard issue on iOS 16 when pushing a new screen and trying to swipe back. The keyboard safe area is not updated when you return from the pushed screen.
Here example 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)
}
From XCode 14.1 I got error in logs
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.
Related
The following code breaks the layout constraints when running on Xcode-14.0.0-Beta 5 with iOS 16.0
struct ContentView: View {
#State var date = Date()
var body: some View {
DatePicker(selection: $date, displayedComponents: .date, label: { EmptyView() })
.datePickerStyle(.graphical)
}
}
Any suggestions how to fix or hide the warning?
Console warning:
2022-08-24 17:16:40.471325+0300 DatePickerProblem[77364:483284] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x600003559180 h=--& v=--& _UIDatePickerCalendarTimeView:0x7fe15c322520.height == 0 (active)>",
"<NSLayoutConstraint:0x60000352bca0 _UIDatePickerCompactTimeLabel:0x7fe15c322bc0.centerY == _UIDatePickerCalendarTimeView:0x7fe15c322520.centerY - 1 (active)>",
"<NSLayoutConstraint:0x60000352bcf0 V:|-(>=0)-[_UIDatePickerCompactTimeLabel:0x7fe15c322bc0] (active, names: '|':_UIDatePickerCalendarTimeView:0x7fe15c322520 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000352bca0 _UIDatePickerCompactTimeLabel:0x7fe15c322bc0.centerY == _UIDatePickerCalendarTimeView:0x7fe15c322520.centerY - 1 (active)>
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.
2022-08-24 17:16:40.471971+0300 DatePickerProblem[77364:483284] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x600003559180 h=--& v=--& _UIDatePickerCalendarTimeView:0x7fe15c322520.height == 0 (active)>",
"<NSLayoutConstraint:0x60000352bd40 UILabel:0x7fe15c324d00.centerY == _UIDatePickerCalendarTimeView:0x7fe15c322520.centerY - 1 (active)>",
"<NSLayoutConstraint:0x60000352bd90 V:|-(>=0)-[UILabel:0x7fe15c324d00] (active, names: '|':_UIDatePickerCalendarTimeView:0x7fe15c322520 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000352bd40 UILabel:0x7fe15c324d00.centerY == _UIDatePickerCalendarTimeView:0x7fe15c322520.centerY - 1 (active)>
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.
2022-08-24 17:16:40.478778+0300 DatePickerProblem[77364:483284] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<_UISystemBaselineConstraint:0x60000355c190 H:[UILabel:0x7fe15c324d00]-(>=NSLayoutAnchorConstraintSpace(8))-[_UIDatePickerCompactTimeLabel:0x7fe15c322bc0] (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x6000035590e0 h=--& v=--& _UIDatePickerCalendarTimeView:0x7fe15c322520.width == 0 (active)>",
"<NSLayoutConstraint:0x60000352bf20 UILabel:0x7fe15c324d00.leading == UILayoutGuide:0x600002f06760'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x60000355c230 _UIDatePickerCompactTimeLabel:0x7fe15c322bc0.trailing == UILayoutGuide:0x600002f06760'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x60000352be30 'UIView-leftMargin-guide-constraint' H:|-(8)-UILayoutGuide:0x600002f06760'UIViewLayoutMarginsGuide' (active, names: '|':_UIDatePickerCalendarTimeView:0x7fe15c322520 )>",
"<NSLayoutConstraint:0x60000352bed0 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600002f06760'UIViewLayoutMarginsGuide']-(8)-|(LTR) (active, names: '|':_UIDatePickerCalendarTimeView:0x7fe15c322520 )>"
)
Will attempt to recover by breaking constraint
<_UISystemBaselineConstraint:0x60000355c190 H:[UILabel:0x7fe15c324d00]-(>=NSLayoutAnchorConstraintSpace(8))-[_UIDatePickerCompactTimeLabel:0x7fe15c322bc0] (active)>
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.
2022-08-24 17:16:40.512015+0300 DatePickerProblem[77364:483284] [UICalendarView] UICalendarView's height is smaller than it can render its content in; defaulting to the minimum height.
2022-08-24 17:16:40.548888+0300 DatePickerProblem[77364:483284] [UICalendarView] UICalendarView's height is smaller than it can render its content in; defaulting to the minimum height.
It seems that the new underlying UICalendarView has some AutoLayout Issues when used by its SwiftUI DatePicker wrapper.
You can see this even better, when you enable the Time Component too (displayedComponents: [.date, .hourAndMinute]). This gives a much longer Auto-Layout warning about the time label constraint being broken.
For me this happens especially when the SwiftUI View is embedded using an UIHostingController which is pushed onto a Navigation Stack.
In my case, I was able to fix it by giving the DatePicker its default width as its frame width:
struct ContentView: View {
#State var date = Date()
var body: some View {
DatePicker(
selection: $date,
displayedComponents: [.date, .hourAndMinute],
label: { EmptyView() }
)
.datePickerStyle(.graphical)
.frame(width: 320) // Bugfix for AutoLayout-Issue
}
}
I've got a SwiftUI View containing a NavigationView and some NavigationLinks. For some reason I got a error message regarding LayoutConstraints. This error is also discussed in this SO Question, with recommended solution setting the navigationViewStyle by .navigationViewStyle(StackNavigationViewStyle()) or .navigationViewStyle(.stack).
However by setting the navigationViewStyle to StackNavigation, the Layout is modified in a non intended way. Using StackNavigation will change the Layout on both IOS and IPadOS to a simple List. Not configuring navigationViewStyle or setting it to .automatic will lead to having a List on IOS and a multiple columns on IPadOS.
Additionally the LayoutConstraints error seems to be a error only occur on IOS.
How can I get rid of the LayoutConstraints error (on IOS) without using StackNavigation? Is it possible to distinguish between IOS/IPadOS?
My View:
struct ProgramView: View {
#ObservedObject var itemViewModel: ItemViewModel
var body: some View {
NavigationView {
VStack {
ForEach(itemViewModel.filteredSessions, id: \.id) { session in
NavigationLink(
destination: SessionDetail(session: session)
) {
SessionRow(session: session)
}
}
// shortened for brevity
}
.navigationTitle("Program")
.navigationBarItems(trailing: UpdateApiButton(itemViewModel: itemViewModel))
}
.navigationViewStyle(.automatic) // default behaviour
.navigationViewStyle(.stack) // Stack; shows a List for IOS+IPadOS; IPadOS should remain multi-column
.navigationViewStyle(.columns) // Uses multi-column also in IOS
}
}
The LayoutConstraints error:
2022-04-06 20:43:49.474918+0200 XXX[1505:41050] [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:0x282b8b2f0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x104c1f610]-(6)-[_UIModernBarButton:0x104c1d7e0'Program'] (active)>",
"<NSLayoutConstraint:0x282b8b340 'CB_Trailing_Trailing' _UIModernBarButton:0x104c1d7e0'Program'.trailing <= _UIButtonBarButton:0x104c1d400.trailing (active)>",
"<NSLayoutConstraint:0x282b813b0 'UINav_static_button_horiz_position' _UIModernBarButton:0x104c1f610.leading == UILayoutGuide:0x2831b9a40'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x282b8b7a0 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x104c1d400]-(6)-[UILayoutGuide:0x2831b9960'UINavigationBarItemContentLayoutGuide'] (active)>",
"<NSLayoutConstraint:0x282b89680 'UINavItemContentGuide-trailing' UILayoutGuide:0x2831b9960'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x104c1c430.trailing (active)>",
"<NSLayoutConstraint:0x282bfce60 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x104c1c430.width == 0 (active)>",
"<NSLayoutConstraint:0x282b89a40 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x2831b9a40'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x104c1c430 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x282b8b2f0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x104c1f610]-(6)-[_UIModernBarButton:0x104c1d7e0'Program'] (active)>
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.
2022-04-06 20:43:49.476126+0200 XXX[1505:41050] [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:0x282b8a760 UIView:0x104c20b90.trailing == _UIBackButtonMaskView:0x104c1afe0.trailing (active)>",
"<NSLayoutConstraint:0x282b80eb0 'Mask_Trailing_Trailing' _UIBackButtonMaskView:0x104c1afe0.trailing == _UIButtonBarButton:0x104c1d400.trailing (active)>",
"<NSLayoutConstraint:0x282b80ff0 'MaskEV_Leading_BIB_Trailing' H:[_UIModernBarButton:0x104c1f610]-(0)-[UIView:0x104c20b90] (active)>",
"<NSLayoutConstraint:0x282b813b0 'UINav_static_button_horiz_position' _UIModernBarButton:0x104c1f610.leading == UILayoutGuide:0x2831b9a40'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x282b8b7a0 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x104c1d400]-(6)-[UILayoutGuide:0x2831b9960'UINavigationBarItemContentLayoutGuide'] (active)>",
"<NSLayoutConstraint:0x282b89680 'UINavItemContentGuide-trailing' UILayoutGuide:0x2831b9960'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x104c1c430.trailing (active)>",
"<NSLayoutConstraint:0x282bfce60 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x104c1c430.width == 0 (active)>",
"<NSLayoutConstraint:0x282b89a40 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x2831b9a40'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x104c1c430 )>"
)
Thanks in advance!
I'm trying to hide the back button name and the solution for this are these two lines:
.navigationBarHidden(true)
.navigationBarTitle("")
Everything works fine except this long console warning which makes debugging really hard as I need to scroll or filter a lot in order to see the desired output.
This line is causing it: .navigationBarTitle("")
Any ideas how to fix this?
Warnings:
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:0x600003823de0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x11fe70c30]-(6)-[_UIModernBarButton:0x11fe6f370' '] (active)>",
"<NSLayoutConstraint:0x600003823e30 'CB_Trailing_Trailing' _UIModernBarButton:0x11fe6f370' '.trailing <= _UIButtonBarButton:0x11fe6eda0.trailing (active)>",
"<NSLayoutConstraint:0x600003850aa0 'UINav_static_button_horiz_position' _UIModernBarButton:0x11fe70c30.leading == UILayoutGuide:0x600002251500'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600003850af0 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x11fe6eda0]-(0)-[UILayoutGuide:0x600002251420'UINavigationBarItemContentLayoutGuide'] (active)>",
"<NSLayoutConstraint:0x60000383b7a0 'UINavItemContentGuide-trailing' UILayoutGuide:0x600002251420'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x11fe58990.trailing (active)>",
"<NSLayoutConstraint:0x600003851270 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x11fe58990.width == 0 (active)>",
"<NSLayoutConstraint:0x60000383bb60 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x600002251500'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x11fe58990 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003823de0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x11fe70c30]-(6)-[_UIModernBarButton:0x11fe6f370' '] (active)>
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.
View:
struct HomeView: View {
var body: some View {
NavigationView {
VStack {
//
}
.navigationBarHidden(true)
.navigationBarTitle("") // Probably at least one of the constraints in the following list is one you don't want.
}
}
}
struct TabViewContainerView: View {
var body: some View {
TabView {
HomeView()
.tabItem {
Image(systemName: "house.fill")
}
.tag(0)
}
}
}
I followed this tutorial of raywenderlich.com to display a context menu when long pressing on a UITableViewCell and came up with the following simplified version to test the implementation:
import UIKit
class ViewController: UITableViewController {
override func tableView(
_ tableView: UITableView,
contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint)
-> UIContextMenuConfiguration? {
let identifier = "\(indexPath.row)" as NSString
return UIContextMenuConfiguration(
identifier: identifier,
previewProvider: nil) { _ in
let shareAction = UIAction(
title: "Share",
image: UIImage(systemName: "square.and.arrow.up")) { _ in
print("share")
}
return UIMenu(title: "", image: nil, children: [shareAction])
}
}
}
The ViewController is a plain UITableViewController with Static Cells in the Storyboard. When I run the application and long press the table cell then the code works as expected, but I get the following AutoLayout errors in the console and I do not understand why?
2020-07-06 15:22:36.879780+0200 Test[1033:453998] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x282308780 h=--& v=--& UIInterfaceActionGroupView:0x102833490.width == 0 (active)>",
"<NSLayoutConstraint:0x28231bca0 UILabel:0x102921c50'Share Item'.leading == UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x28231bcf0 UILabel:0x102921c50'Share Item'.trailing == UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x282315db0 _UIInterfaceActionGroupHeaderScrollView:0x103063600.width == _UIPreviewPlatterActionsTitleView:0x102921590'Share Item'.width (active)>",
"<NSLayoutConstraint:0x28231a800 H:|-(0)-[_UIContentConstraintsLayoutGuide:0x1028336f0''] (active, names: '|':UIInterfaceActionGroupView:0x102833490 )>",
"<NSLayoutConstraint:0x28231a850 _UIContentConstraintsLayoutGuide:0x1028336f0''.trailing == UIInterfaceActionGroupView:0x102833490.trailing (active)>",
"<NSLayoutConstraint:0x28232fd40 _UIInterfaceActionGroupHeaderScrollView:0x103063600.width == _UIContentConstraintsLayoutGuide:0x1028336f0''.width (active)>",
"<NSLayoutConstraint:0x28231cfa0 'UIView-leftMargin-guide-constraint' H:|-(12)-[UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIPreviewPlatterActionsTitleView:0x102921590'Share Item' )>",
"<NSLayoutConstraint:0x28231bc50 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide']-(12)-|(LTR) (active, names: '|':_UIPreviewPlatterActionsTitleView:0x102921590'Share Item' )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x28231bcf0 UILabel:0x102921c50'Share Item'.trailing == UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'.trailing (active)>
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.
2020-07-06 15:22:36.881528+0200 Test[1033:453998] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x2823088c0 h=--& v=--& UIInterfaceActionGroupView:0x102833490.height == 0 (active)>",
"<NSLayoutConstraint:0x28231b070 groupView.actionsSequence....height >= 44 (active, names: groupView.actionsSequence...:0x103062e00 )>",
"<NSLayoutConstraint:0x2823135c0 V:[_UIInterfaceActionGroupHeaderScrollView:0x103063600]-(0)-[_UIInterfaceActionVibrantSeparatorView:0x10283ab40] (active)>",
"<NSLayoutConstraint:0x2823140a0 V:[_UIInterfaceActionVibrantSeparatorView:0x10283ab40]-(0)-[groupView.actionsSequence...] (active, names: groupView.actionsSequence...:0x103062e00 )>",
"<NSLayoutConstraint:0x28231ada0 UIInterfaceActionGroupView:0x102833490.top == _UIContentConstraintsLayoutGuide:0x1028336f0''.top (active)>",
"<NSLayoutConstraint:0x28231adf0 V:[_UIContentConstraintsLayoutGuide:0x1028336f0'']-(0)-| (active, names: '|':UIInterfaceActionGroupView:0x102833490 )>",
"<NSLayoutConstraint:0x282314190 _UIInterfaceActionGroupHeaderScrollView:0x103063600.top == _UIContentConstraintsLayoutGuide:0x1028336f0''.top (active)>",
"<NSLayoutConstraint:0x2823141e0 groupView.actionsSequence....bottom == _UIContentConstraintsLayoutGuide:0x1028336f0''.bottom (active, names: groupView.actionsSequence...:0x103062e00 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x28231b070 groupView.actionsSequence....height >= 44 (active, names: groupView.actionsSequence...:0x103062e00 )>
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.
I am using a navigation bar with a prompt, looking like this:
I receive the following auto layout warnings in the console:
2019-09-01 21:26:03.225576+0200 Hortus[85622:2386450] [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:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15c20 UILabel:0x7fc9eb816f50'Testen'.leading >= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d16a30 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002d15c20 UILabel:0x7fc9eb816f50'Testen'.leading >= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.leading (active)>
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.
2019-09-01 21:26:03.226198+0200 Hortus[85622:2386450] [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:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15540 UILabel:0x7fc9eb816f50'Testen'.trailing <= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d14320 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide']-(8)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
"<NSAutoresizingMaskLayoutConstraint:0x60000043be30 h=--& v=--& _UINavigationBarModernPromptView:0x7fb3c6416640.width == 0 (active)>",
"<NSLayoutConstraint:0x600000421400 UILabel:0x7fb3c66d8bf0'Plant guide'.centerX == _UINavigationBarModernPromptView:0x7fb3c6416640.centerX (active)>",
"<NSLayoutConstraint:0x600000421f90 UILabel:0x7fb3c66d8bf0'Plant guide'.trailing <= UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600000421e00 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide']-(20)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fb3c6416640 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002d15540 UILabel:0x7fc9eb816f50'Testen'.trailing <= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.trailing (active)>
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.
These warnings are given for the prompt in the navigation bar, but I do not set the autolayout constraints for the navigation bar. This should be handled by IOS itself.
What can I do to fix these warnings?
[Edit] The warnings are given in prepare() when segueing to the view controller. I set the prompt in prepare(). The segue is to a storyboard reference and is defined as 'present modally'. The storyboard reference references a UINavigationController. The prompt is set on the root view controller of the navigation controller.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
switch identifier {
case "editImage":
let nc = segue.destination as? TTImageNavigationController
if let rvc = nc?.rootViewController as? TTImageEditorController {
rvc.navigationItem.prompt = navigationItem.prompt
}
default:
break
}
}
}
[EDIT] It seems that the problem is not clear to most of the people who react. Again... I do not set any auto layout settings in code or storyboard. The problem occurs in the navigation bar after setting the prompt in the prepare() function prior to the segue. The code is given above. Any reactions that say that I have to change or check my constraints are not helpful, because there are no constraints to check!
[EDIT] As requested by Mohsen, I created a small sample project on github: https://bitbucket.org/Leontien/navigationbarautolayoutwarning/src/master/
It’s not your bug. It’s Apple’s bug. Ignore the console. File a report with Apple and move on.
Set priority to your constraints. This will fulfill constraints according to priority. Please refer this link.
you set centerX for the label and set leading and trailing for right and left buttons, also you didn't set any width constraint for UILabel
"<NSLayoutConstraint:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15c20 UILabel:0x7fc9eb816f50'Testen'.leading >= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d16a30 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
.
"<NSLayoutConstraint:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15540 UILabel:0x7fc9eb816f50'Testen'.trailing <= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d14320 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide']-(8)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
"<NSAutoresizingMaskLayoutConstraint:0x60000043be30 h=--& v=--& _UINavigationBarModernPromptView:0x7fb3c6416640.width == 0 (active)>",
"<NSLayoutConstraint:0x600000421400 UILabel:0x7fb3c66d8bf0'Plant guide'.centerX == _UINavigationBarModernPromptView:0x7fb3c6416640.centerX (active)>",
"<NSLayoutConstraint:0x600000421f90 UILabel:0x7fb3c66d8bf0'Plant guide'.trailing <= UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600000421e00 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide']-(20)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fb3c6416640 )>"
for solve this warning you should remove leading and trailing constraint from UILabel and set left button with leading to superview and right button's trailing to superview as well.
or you can use a navigation bar object, it has a label and also you can add barButtonItem to it.
you can add width constraint for the UILabel but it will be conflict on another devices when you run it on some other devices
This helps to debug broken constraint issue by providing a more readable output
Create an extension for NSLayoutConstraint
extension NSLayoutConstraint {
override open var description: String {
let id = identifier ?? ""
return "Constraint ID: \(id), constant: \(constant)"
}
}
set a unique identifier for every constraint in the storyboard
you'll get a more readable output pointing out which constraint id is broken
change the priority for broken constraint