gpt4 book ai didi

iOS:是否可以调整 Twitter 和/或 Facebook 登录按钮的大小?

转载 作者:行者123 更新时间:2023-11-28 21:44:55 25 4
gpt4 key购买 nike

我想在我的移动应用程序中添加 Twitter 和 Facebook 身份验证按钮。目前使用 XCode 6 和 Facebook 和 Twitter 的最新 SDK。我设法将这两个按钮集成到我的授权屏幕中,但尺寸确实不同,导致了一个非常糟糕的设计问题; )

enter image description here

- (void)viewDidLoad {
[super viewDidLoad];
// facebook login
FBSDKLoginButton *fbLogin = [[FBSDKLoginButton alloc] init];
fbLogin.center = self.view.center;
[self.view addSubview:fbLogin];

// twitter login
TWTRLogInButton *twLogin = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
// ...
}];
twLogin.center = CGPointMake(self.view.center.x, self.view.center.y+50.0);
[self.view addSubview:twLogin];
}

有人知道如何调整这些按钮的大小吗?

EDIT-1:根据 Sega-Zero 的回答,我得到以下错误:

2015-05-31 11:20:12.204 TestApp[10477:3081595] [Fabric] Unable to locate application icon
2015-05-31 11:20:12.251 TestApp[10477:3081595] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
Expected a view
H:fbLogin(==twLogin)
^'

EDIT-2:根据 Sega-Zero 的更正答案,我得到以下错误:

2015-05-31 11:39:11.433 Quiz Cup[10486:3083839] [Fabric] Unable to locate application icon
2015-05-31 11:39:11.488 Quiz Cup[10486:3083839] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x170088840 FBSDKLoginButton:0x124e12690'Log in'.width == TWTRLogInButton:0x124e15840.width>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2015-05-31 11:39:11.490 Quiz Cup[10486:3083839] View hierarchy unprepared for constraint.
Constraint: <NSLayoutConstraint:0x170088840 FBSDKLoginButton:0x124e12690'Log in'.width == TWTRLogInButton:0x124e15840.width>
Container hierarchy:
<FBSDKLoginButton: 0x124e12690; baseClass = UIButton; frame = (296.5 497; 175 30); opaque = NO; layer = <CALayer: 0x170036d80>>
| <UIButtonLabel: 0x124e147a0; frame = (0 0; 0 0); text = 'Log in'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x170087f80>>
View not found in container hierarchy: <TWTRLogInButton: 0x124e15840; baseClass = UIButton; frame = (244 542; 280 40); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x1740322e0>>
That view's superview: <UIView: 0x124e11960; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0x170036c00>>
2015-05-31 11:39:11.497 Quiz Cup[10486:3083839] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSLayoutConstraint:0x170088840 FBSDKLoginButton:0x124e12690'Log in'.width == TWTRLogInButton:0x124e15840.width> view:<FBSDKLoginButton: 0x124e12690; baseClass = UIButton; frame = (296.5 497; 175 30); opaque = NO; layer = <CALayer: 0x170036d80>>'

最佳答案

只需为两个按钮设置最小宽度/高度限制 + 相等的宽度/高度。如果您更喜欢通过代码来做到这一点,这可能看起来像这样:

[fbLoginParent addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[fbLogin(==twLogin)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(fbLogin, twLogin)]];
[fbLoginParent addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[fbLogin(==twLogin)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(fbLogin, twLogin)]];
[fbLogin addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[fbLogin(>=100)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(fbLogin)]];
[fbLogin addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[fbLogin(>=26)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(fbLogin)]];

关于iOS:是否可以调整 Twitter 和/或 Facebook 登录按钮的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30555497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com