Nested UIStackViews Broken Constraints

后端 未结 7 611
故里飘歌
故里飘歌 2021-01-31 02:59

I have a complex view hierarchy, built in Interface Builder, with nested UIStackViews. I get \"unsatisfiable constraints\" notices every time I hide some of my inner stackviews.

7条回答
  •  遥遥无期
    2021-01-31 03:51

    In my case I was adding width and height constraint to a navigation bar button, as per the advice above I only added lower priority to the constraints.

    open func customizeNavigationBarBackButton() {
            let _selector = #selector(UIViewController._backButtonPressed(_:))
            let backButtonView = UIButton(type: .custom)
            backButtonView.setImage(UIImage(named: "icon_back"), for: .normal)
            backButtonView.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: -30, bottom: 0, right: 0)
            backButtonView.snp.makeConstraints { $0.width.height.equalTo(44).priority(900) }
            backButtonView.addTarget(self, action: _selector, for: .touchUpInside)
    
            let backButton = UIBarButtonItem(customView: backButtonView)
            self.navigationItem.leftBarButtonItem = backButton
        }
    

提交回复
热议问题