3

iPad を回転すると、アニメーション化されたすべてのコンポーネント (ビュー/ボタンなど) が、最初にロードされたときの元の位置に戻ります。これを防ぐ方法はありますか?

ボタンをクリックしたときにオブジェクトをアニメーション化する方法は次のとおりです。

- (IBAction)button1Pressed:(id)sender{

    [UIView animateWithDuration:ANIMATION_SPEED
                          delay:0.0
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:(void (^)(void)) ^{
                         self.view.userInteractionEnabled = NO;
                         _button1.center = CGPointMake(73.01, 419.0);
                         _button2.center = CGPointMake(750.0, 419.0);
                         _button3.center = CGPointMake(850.0, 419.0);
                         _button4.center = CGPointMake(950.0, 419.0);

                         CGRect theFrame = _loginView.frame;
                         theFrame.size.width = 576.f;
                         _View1.frame = theFrame;
                         _View2.frame = CGRectMake(_button2.center.x + 44.0, _button2.center.y / 2 - 89.0, 0.0, 597.0);
                         _View3.frame = CGRectMake(_button3.center.x + 44.0, _button3.center.y / 2 - 89.0, 0.0, 597.0);
                         _4View.frame = CGRectMake(_button4.center.x + 44.0, _button4.center.y / 2 - 89.0, 0.0, 597.0);
                     }
                     completion:^(BOOL finished){
                         self.view.userInteractionEnabled = YES;
                     }];
}

私はまだかなり新しいので、すべての詳細をいただければ幸いです:)

4

2 に答える 2

0

「インターフェースビルダードキュメント」の下にある自動レイアウトをオフにすると、これがすばやく修正されました:)

于 2013-12-11T16:07:36.663 に答える
0

アニメーション化するインターフェイスの制約を作成することをお勧めします。次に、ビュー要素と同様に、これらの制約のヘッダー ファイルへの参照を追加します。

ここに画像の説明を入力

ビューをアニメーション化する場合は、その制約を更新し、ビューのレイアウトを要求する必要があります。

[UIView animateWithDuration:0.2
                         animations:^{
                             //in this case, I add 44 to my button Y position, so it will goes down 44px 
                             buttonYConstraint.constant += 44;
                             [self.view layoutIfNeeded];
                         }
]
//Now don't forget to update constraints
[self.view updateConstraints];
于 2013-11-05T13:16:35.043 に答える