0
votes

I want to resize facebook's LoginButton, but I am getting this error

[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:0x1c4283ed0 h=--& v=--& FBSDKLoginButton: 0x104432fd0'Log in'.height == 40 (active)",

"NSLayoutConstraint:0x1c42828f0 FBSDKLoginButton:0x104432fd0'Log in'.height == 28 (active)>" )

Will attempt to recover by breaking constraint

NSLayoutConstraint:0x1c42828f0 FBSDKLoginButton:0x104432fd0'Log in'.height == 28 (active)>

I've searched a lot, and have no idea how height == 28 constraint exists.

Creating LoginButton:

private var didLayoutSubviews = false {
    didSet {
        //I've use storyboard first, but couldn't make it work with resizing 
        self.facebookSignUpButton.removeFromSuperview()

        self.facebookSignUpButton = LoginButton(readPermissions: [.email, .publicProfile])

        //I've tried to set `isActive = false`
        self.facebookSignUpButton.constraints.forEach({self.facebookSignUpButton.removeConstraint($0)})

        self.facebookSignUpButton.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(self.facebookSignUpButton)
        self.facebookSignUpButton.heightAnchor.constraint(equalToConstant: self.googleSignUpButton.frame.height - 8).isActive = true
        self.facebookSignUpButton.widthAnchor.constraint(equalToConstant: self.googleSignUpButton.frame.width - 8).isActive = true
        self.facebookSignUpButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
        self.facebookSignUpButton.topAnchor.constraint(equalTo: self.separatorLabel.bottomAnchor, constant: 20).isActive = true
        self.facebookSignUpButton.bottomAnchor.constraint(equalTo: self.googleSignUpButton.topAnchor, constant: -10).isActive = true
        self.facebookSignUpButton.delegate = self.presenter
        self.view.layoutIfNeeded()
    }
}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    if !self.didLayoutSubviews {
        self.didLayoutSubviews = true
    }
} 
1

1 Answers

0
votes

The notification to developers is in the Facebook Guidelines for 4.19 . This has already been discussed on SO here.

Personally, I was only able to make this work with a custom login button in Swift 4.