我想调整facebook LoginButton
的大小,但我收到此错误
[LayoutConstraints]无法同时满足约束。 可能至少下列列表中的一个约束是您不想要的约束。
试试这个:
(1)看看每个约束并试图找出你不期望的东西;
(2)找到添加了不需要的约束或约束的代码并修复它。
(注意:如果你看到你不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性translatesAutoresizingMaskIntoConstraints的文档)
( “NSAutoresizingMaskLayoutConstraint:0x1c4283ed0 h = - & v = - & FBSDKLoginButton:0x104432fd0'Log in'.height == 40(active)”,
“NSLayoutConstraint:0x1c42828f0 FBSDKLoginButton:0x104432fd0'Log in'.height == 28(active)>” )
将尝试通过违反约束来恢复
NSLayoutConstraint:0x1c42828f0 FBSDKLoginButton:0x104432fd0'Log in'.height == 28(有效)>
我搜索了很多,并且不知道height == 28
约束是如何存在的。
创建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
}
}
答案 0 :(得分:0)
向开发人员发送的通知位于Facebook Guidelines for 4.19。这已经discussed on SO here了。
就个人而言,我只能使用Swift 4中的自定义登录按钮来完成这项工作。