Toolbar avec bouton problème!

Bonsoir, les codeurs, je remarque que lorsque l’on met un bouton dans la toolbar la console crie et crache un message de problème de contrainte. je ne trouve pas la solution.

version Xcode 13.2.1 c’est un bug ?

petit exemple pour illustrer mon propos.

import SwiftUI

struct ContentView: View {
var body: some View {
NavigationView {
Text(« Bonjour »).padding()
.navigationTitle(« SwiftUI »)
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
Button("1er bouton ") {
print(« Pressed 1 »)
}

                    Spacer()
                    
                    Button("Second bouton 2") {
                        print("pressed 2")
                    }
                }
            }
    }
}

}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

" 2022-01-11 22:52:43.100494+0100 essai bouton[7848:142410] [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:0x600002945630 ‹ BIB_Leading_Leading › H:|-(0)-[_UIModernBarButton:0x7ff6d8f18440] (active, names: ‹ | ›:_UIButtonBarButton:0x7ff6d8f14dc0 )>",

"<NSLayoutConstraint:0x6000029463a0 ‹ UINav_static_button_horiz_position › _UIModernBarButton:0x7ff6d8f18440.leading == UILayoutGuide:0x600003357100’UIViewLayoutMarginsGuide’.leading (active)>",

"<NSLayoutConstraint:0x600002946490 ‹ UINavItemContentGuide-leading › H:[_UIButtonBarButton:0x7ff6d8f14dc0]-(6)-[UILayoutGuide:0x600003357020’UINavigationBarItemContentLayoutGuide’] (active)>",

"<NSLayoutConstraint:0x60000292e080 ‹ UINavItemContentGuide-trailing › UILayoutGuide:0x600003357020’UINavigationBarItemContentLayoutGuide’.trailing == _UINavigationBarContentView:0x7ff6d8f139f0.trailing (active)>",

"<NSLayoutConstraint:0x600002929c20 ‹ UIView-Encapsulated-Layout-Width › _UINavigationBarContentView:0x7ff6d8f139f0.width == 0 (active)>",

"<NSLayoutConstraint:0x60000292e440 ‹ UIView-leftMargin-guide-constraint › H:|-(8)-UILayoutGuide:0x600003357100’UIViewLayoutMarginsGuide’ (active, names: ‹ | ›:_UINavigationBarContentView:0x7ff6d8f139f0 )>"

)

Will attempt to recover by breaking constraint

<NSLayoutConstraint:0x600002945630 ‹ BIB_Leading_Leading › H:|-(0)-[_UIModernBarButton:0x7ff6d8f18440] (active, names: ‹ | ›:_UIButtonBarButton:0x7ff6d8f14dc0 )>

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-01-11 22:52:43.101536+0100 essai bouton[7848:142410] [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:0x600002944b40 UIView:0x7ff70991c250.trailing == _UIBackButtonMaskView:0x7ff70991b8f0.trailing (active)>",

"<NSLayoutConstraint:0x600002945c70 ‹ Mask_Trailing_Trailing › _UIBackButtonMaskView:0x7ff70991b8f0.trailing == _UIButtonBarButton:0x7ff6d8f14dc0.trailing (active)>",

"<NSLayoutConstraint:0x600002945db0 ‹ MaskEV_Leading_BIB_Trailing › H:[_UIModernBarButton:0x7ff6d8f18440]-(0)-[UIView:0x7ff70991c250] (active)>",

"<NSLayoutConstraint:0x6000029463a0 ‹ UINav_static_button_horiz_position › _UIModernBarButton:0x7ff6d8f18440.leading == UILayoutGuide:0x600003357100’UIViewLayoutMarginsGuide’.leading (active)>",

"<NSLayoutConstraint:0x600002946490 ‹ UINavItemContentGuide-leading › H:[_UIButtonBarButton:0x7ff6d8f14dc0]-(6)-[UILayoutGuide:0x600003357020’UINavigationBarItemContentLayoutGuide’] (active)>",

"<NSLayoutConstraint:0x60000292e080 ‹ UINavItemContentGuide-trailing › UILayoutGuide:0x600003357020’UINavigationBarItemContentLayoutGuide’.trailing == _UINavigationBarContentView:0x7ff6d8f139f0.trailing (active)>",

"<NSLayoutConstraint:0x600002929c20 ‹ UIView-Encapsulated-Layout-Width › _UINavigationBarContentView:0x7ff6d8f139f0.width == 0 (active)>",

"<NSLayoutConstraint:0x60000292e440 ‹ UIView-leftMargin-guide-constraint › H:|-(8)-UILayoutGuide:0x600003357100’UIViewLayoutMarginsGuide’ (active, names: ‹ | ›:_UINavigationBarContentView:0x7ff6d8f139f0 )>"

)

Will attempt to recover by breaking constraint

<NSLayoutConstraint:0x600002944b40 UIView:0x7ff70991c250.trailing == _UIBackButtonMaskView:0x7ff70991b8f0.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.

2022-01-11 22:52:43.107470+0100 essai bouton[7848:142410] [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:0x600002945680 ‹ BIB_Trailing_CB_Leading › H:[_UIModernBarButton:0x7ff6d8f18440]-(6)-[_UIModernBarButton:0x7ff6d8f157a0’SwiftUI’] (active)>",

"<NSLayoutConstraint:0x6000029456d0 ‹ CB_Trailing_Trailing › _UIModernBarButton:0x7ff6d8f157a0’SwiftUI’.trailing <= _UIButtonBarButton:0x7ff6d8f14dc0.trailing (active)>",

"<NSLayoutConstraint:0x6000029463a0 ‹ UINav_static_button_horiz_position › _UIModernBarButton:0x7ff6d8f18440.leading == UILayoutGuide:0x600003357100’UIViewLayoutMarginsGuide’.leading (active)>",

"<NSLayoutConstraint:0x600002946490 ‹ UINavItemContentGuide-leading › H:[_UIButtonBarButton:0x7ff6d8f14dc0]-(6)-[UILayoutGuide:0x600003357020’UINavigationBarItemContentLayoutGuide’] (active)>",

"<NSLayoutConstraint:0x60000292e080 ‹ UINavItemContentGuide-trailing › UILayoutGuide:0x600003357020’UINavigationBarItemContentLayoutGuide’.trailing == _UINavigationBarContentView:0x7ff6d8f139f0.trailing (active)>",

"<NSLayoutConstraint:0x600002929c20 ‹ UIView-Encapsulated-Layout-Width › _UINavigationBarContentView:0x7ff6d8f139f0.width == 0 (active)>",

"<NSLayoutConstraint:0x60000292e440 ‹ UIView-leftMargin-guide-constraint › H:|-(8)-UILayoutGuide:0x600003357100’UIViewLayoutMarginsGuide’ (active, names: ‹ | ›:_UINavigationBarContentView:0x7ff6d8f139f0 )>"

)

Will attempt to recover by breaking constraint

<NSLayoutConstraint:0x600002945680 ‹ BIB_Trailing_CB_Leading › H:[_UIModernBarButton:0x7ff6d8f18440]-(6)-[_UIModernBarButton:0x7ff6d8f157a0’SwiftUI’] (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.

Bonjour @titastus

Je suis tombé sur ce lien, qui peut peut-être t’aider :

Merci Merci effectivement ton lien m’aide beaucoup
j’étais sur une fausse piste.

1 « J'aime »