SwiftUI TextField: Keyboard does not show up on tapped - ios

I have a simple TextField in a HStack together with a button
HStack {
TextField("Level Name", text: $levelName)
.font(.title)
.padding(10)
.background(
RoundedRectangle(cornerRadius: 15)
.strokeBorder(Color.primary.opacity(0.5), lineWidth: 3))
Button(action: {
}) {
Text("Submit").font(.title)
}
}
Clicking on the textfield does not display the keyboard on my emulator, giving the console warning:
[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:0x600002bba8f0 h=--& v=--& _UIButtonBarButton:0x7fdbcbc52e90.height == 0 (active)>",
"<NSLayoutConstraint:0x600002bb4050 _UIUCBKBSelectionBackground:0x7fdbcbc53890.bottom == _UIButtonBarButton:0x7fdbcbc52e90.bottom - 6 (active)>",
"<NSLayoutConstraint:0x600002bbff70 V:|-(6)-[_UIUCBKBSelectionBackground:0x7fdbcbc53890] (active, names: '|':_UIButtonBarButton:0x7fdbcbc52e90 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002bb4050 _UIUCBKBSelectionBackground:0x7fdbcbc53890.bottom == _UIButtonBarButton:0x7fdbcbc52e90.bottom - 6 (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.

Your code works. Keyboard shows up. Running iOS 15.1.
struct TestView: View {
#State var levelName = ""
var body: some View {
HStack {
TextField("Level Name", text: $levelName)
.font(.title)
.padding(10)
.background(
RoundedRectangle(cornerRadius: 15)
.strokeBorder(Color.primary.opacity(0.5), lineWidth: 3))
Button(action: {
}) {
Text("Submit").font(.title)
}
}
}
}

Related

iOS 16 SwiftUI keyboard safe area bug when swipe back

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.

DatePicker with graphical style breaks layout constraints on iOS 16.0

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
}
}

SwiftUI LayoutConstraints NavigationView navigationViewStyle

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!

SwiftUI navigationBarTitle causes console warning

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)
}
}
}

Add constraints to button in swift (Apple iOS Tutorial)

I am programming Apples Tutorial (Chapter: "Add Buttons to the View") for iOS Development. Just copying the following code I get a different result:
import UIKit
#IBDesignable class RatingControl: UIStackView {
//MARK: Properties
private var ratingButtons = [UIButton]()
var rating = 0
#IBInspectable var starSize: CGSize = CGSize(width: 44.0, height: 44.0)
#IBInspectable var starCount: Int = 5
//MARK: Initialisation
override init(frame: CGRect) {
super.init(frame: frame)
setupButtons()
}
required init(coder: NSCoder) {
super.init(coder: coder)
setupButtons()
}
//MARK: Private Methods
private func setupButtons() {
// Create the button
let button = UIButton()
button.backgroundColor = UIColor.red
// Add constraints
button.translatesAutoresizingMaskIntoConstraints = false
button.heightAnchor.constraint(equalToConstant: starSize.height).isActive = true
button.widthAnchor.constraint(equalToConstant: starSize.width).isActive = true
// Setup the button action
button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(button:)), for: .touchUpInside)
// Add the button to the stack
addArrangedSubview(button)
// Add the new button to the rating button array
ratingButtons.append(button)
}
//MARK: Button Action
func ratingButtonTapped(button: UIButton) {
print("Button pressed 👍")
}
}
The constraints seem not to be working. My red button has exactly the same size as its super stack view. It is not constrained to 44x44.
The console reports that not all constraints could simultaneously be satisfied:
2016-12-25 18:43:02.375251 FoodTracker[13644:1695258] [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:0x600000092160 UIButton:0x7ff15f40a740.width == 44 (active)>",
"<NSLayoutConstraint:0x608000095a90 'UISV-canvas-connection' FoodTracker.RatingControl:0x7ff15f6116c0.leading == UIButton:0x7ff15f40a740.leading (active)>",
"<NSLayoutConstraint:0x608000095b30 'UISV-canvas-connection' H:[UIButton:0x7ff15f40a740]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x7ff15f6116c0 )>",
"<NSLayoutConstraint:0x608000095630 'UIView-Encapsulated-Layout-Width' FoodTracker.RatingControl:0x7ff15f6116c0.width == 200 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000092160 UIButton:0x7ff15f40a740.width == 44 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-12-25 18:43:02.376266 FoodTracker[13644:1695258] [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:0x600000091e90 UIButton:0x7ff15f40a740.height == 44 (active)>",
"<NSLayoutConstraint:0x608000095b80 'UISV-canvas-connection' FoodTracker.RatingControl:0x7ff15f6116c0.top == UIButton:0x7ff15f40a740.top (active)>",
"<NSLayoutConstraint:0x608000095c70 'UISV-canvas-connection' V:[UIButton:0x7ff15f40a740]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x7ff15f6116c0 )>",
"<NSLayoutConstraint:0x608000095680 'UIView-Encapsulated-Layout-Height' FoodTracker.RatingControl:0x7ff15f6116c0.height == 110 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000091e90 UIButton:0x7ff15f40a740.height == 44 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
However, I have not defined other constraints to the stack view except the ones in the class above. Also in the Interface Builder there are no additional constraints for the stack view in the outline. Where do the 'UISV-canvas-connection' come from?
Found the same issue while working with Apple's tutorials, and did make the mistake of creating Horizontal Stack View outside the Vertical Stack View.
After dragging it back to Vertical Stack View, it works for me :)

Resources