0

UIButtonインスタンス化するときに a のサイズを設定して、すぐに使用できるようにするにはどうすればよいNSLayoutConstraintですか?

コード:

UIButtonRaisedSilver *loginButton = [UIButtonRaisedSilver buttonWithType:UIButtonTypeCustom];
[loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
[loginButton setTitle:@"Log in" forState:UIControlStateNormal];

NSDictionary *views = @{@"tableView" : self.tableView, @"loginButton": loginButton, @"signupButton": signupButton};

[NSLayoutConstraint constraintsWithVisualFormat:@"V:[tableView]-50-[loginButton()]"
                                        options:NSLayoutFormatAlignAllCenterX
                                        metrics:nil
                                          views:views];
4

1 に答える 1

1

幅と高さは、iOS6/(OSX 10.8) の制約システムの一部でもあることがわかりました (10.8 はまだ Mac OS 用に開発されていないと思います)。

制約が高さに対して垂直であることを確認し、以下のように括弧内に高さを設定してください...

例えば:

[NSLayoutConstraint constraintsWithVisualFormat:@"V:[loginButton(30)]"
                                    options:NSLayoutFormatAlignAllCenterX
                                    metrics:nil
                                      views:views];
于 2012-10-09T19:43:28.847 に答える