Tuesday, September 27, 2022
HomeiOS Developmentios - LayoutConstraints error when altering from a Tab to a different...

ios – LayoutConstraints error when altering from a Tab to a different Tab (TabView)


I’ve the beneath BaseView which holds a TabView, however I’ve some layoutConstrains errors when navigation to Exercises [.tag(Page.workouts)] tab.

WorkoutTabView has solely a Textual content inside.

If I delete the NavigationView (verify code beneath), the errors doesn’t happen anymore.

Can anybody clarify and possibly assist me repair this? I can run the app however I do not assume is a good suggestion to neglect concerning the errors and simply proceed creating the app. 🙂

These are the errors:

2022-05-08 14:05:36.004019+0300 FitnessApp[3198:96825] [LayoutConstraints] Unable to concurrently fulfill constraints.
In all probability not less than one of many constraints within the following record is one you don’t need.
Do that:
(1) have a look at every constraint and take a look at to determine which you do not anticipate;
(2) discover the code that added the undesirable constraint or constraints and repair it.
“<NSLayoutConstraint:0x600003b6e9e0 ‘BIB_Trailing_CB_Leading’ H:[_UIModernBarButton:0x134581790]-(6)-[_UIModernBarButton:0x134546800’Workouts’] (energetic)>”,
“<NSLayoutConstraint:0x600003b6e990 ‘CB_Trailing_Trailing’ _UIModernBarButton:0x134546800’Exercises’.trailing <= _UIButtonBarButton:0x134561170.trailing (energetic)>”,
“<NSLayoutConstraint:0x600003b6fa70 ‘UINav_static_button_horiz_position’ _UIModernBarButton:0x134581790.main == UILayoutGuide:0x600002168c40’UIViewLayoutMarginsGuide’.main (energetic)>”,
“<NSLayoutConstraint:0x600003b6fb60 ‘UINavItemContentGuide-leading’ H:[_UIButtonBarButton:0x134561170]-(6)-[UILayoutGuide:0x6000021689a0’UINavigationBarItemContentLayoutGuide’] (energetic)>”,
“<NSLayoutConstraint:0x600003b73b10 ‘UINavItemContentGuide-trailing’ UILayoutGuide:0x6000021689a0’UINavigationBarItemContentLayoutGuide’.trailing == _UINavigationBarContentView:0x13453e340.trailing (energetic)>”,
“<NSLayoutConstraint:0x600003b14e60 ‘UIView-Encapsulated-Structure-Width’ _UINavigationBarContentView:0x13453e340.width == 0 (energetic)>”,
“<NSLayoutConstraint:0x600003b73ed0 ‘UIView-leftMargin-guide-constraint’ H:|-(8)-UILayoutGuide:0x600002168c40’UIViewLayoutMarginsGuide’ (energetic, names: ‘|’:_UINavigationBarContentView:0x13453e340 )>”

Will try to get well by breaking constraint
<NSLayoutConstraint:0x600003b6e9e0 ‘BIB_Trailing_CB_Leading’ H:[_UIModernBarButton:0x134581790]-(6)-[_UIModernBarButton:0x134546800’Workouts’] (energetic)>

struct BaseView: View {
    @EnvironmentObject var workoutManager: WorkoutManager
    @EnvironmentObject var dateModel: DateModel
    @EnvironmentObject var viewRouter: ViewRouter

    @State non-public var isShowingAddWorkoutSheet = false

    var physique: some View {
        TabView(choice: $viewRouter.currentTab) {
                .tabItem {
                    Picture(systemName: "home")
                    Textual content("House")
                .tag(Web page.house)

                .tabItem {
                    Picture(systemName: "calendar")
                    Textual content("Calendar")
                .tag(Web page.calendar)

            NavigationView {
                .toolbar {
                    Button {
                    } label: {
                        Picture(systemName: "plus")
                    .accessibilityLabel("Add new Exercise")
                    .sheet(isPresented: $isShowingAddWorkoutSheet) {
            .tabItem {
                Picture(systemName: "record.bullet.rectangle")
                Textual content("Exercises")
            .tag(Web page.exercises)

                .tabItem {
                    Picture(systemName: "individual")
                    Textual content("Profile")
                .tag(Web page.profile)

struct WorkoutTabView: View {
    @EnvironmentObject var workoutManager: WorkoutManager
    @EnvironmentObject var dateModel: DateModel

    var physique: some View {
        Textual content("Exercises")



Most Popular

Recent Comments