0

我正在制作一个带有两个 UITextField、一个忘记密码按钮和两个附加按钮(signInButtoncreateAccountButton)的欢迎屏幕。inputsView这两个按钮与文本字段一起放置在 UIView ( ) 中。

只要其中一个文本字段被聚焦,我就会为屏幕设置动画以适应键盘、调整createAccountButton按钮大小并在signInButton. 我正在使用以下代码:

[UIView animateWithDuration:.48 delay:0 usingSpringWithDamping:1 initialSpringVelocity:.42 options:(UIViewAnimationOptionBeginFromCurrentState) animations:^{

    CGRect f3 = inputsView.frame;
    f3.origin.y = 112;
    inputsView.frame = f3;

    [inputsView layoutSubviews];

    CGRect f4 = createAccountButton.bounds;
    f4.size.width = 160;
    createAccountButton.bounds = f4;

    CGRect f5 = createAccountButton.frame;
    f5.origin.x = 160;
    createAccountButton.frame = f5;

    CGRect f6 = signInButton.frame;
    f6.origin.x = 0;
    signInButton.frame = f6;

    CGRect f7 = buttonSeparator.frame;
    f7.origin.x = 160;
    buttonSeparator.frame = f7;

    [signInButton layoutSubviews];
    [createAccountButton layoutSubviews];

} completion:nil];

这一切都很好,但是如果我然后点击忘记密码按钮打开 UIAlertView,按钮会弹回原来的位置。奇怪的buttonSeparator是, 1px UIView 不会回弹。

我是否忘记了什么,或者这是 iOS 7 SDK 中的错误?

4

1 回答 1

3

您很可能正在使用自动布局

禁用自动布局属性。

发生的原因:自动布局将使用当前约束将视图更新到其原始位置。

希望能帮助到你。

于 2013-11-17T17:42:17.083 回答