0

なぜ機能しないのかわかりません。

私がやりたいのは、viewDidLoad の単純な UIView アニメーションだけです。

これが私のコードです:

[UIView animateWithDuration:3.0f animations:^{
    [self.headline setCenter:CGPointMake(0.0, 200.0)];
}];

何も起こりません。このような特定のオブジェクトでアニメーション メソッドを呼び出す一般的なアプローチをテストすると、次のようになります。

[UIView animateWithDuration:3.0f animations:^{
    [self.headline setAlpha:0.0];
}];

できます!!!ビューを画面上で移動できないのはなぜですか? 最新の Xcode 4.5 を使用しています。

アドバイスをありがとう!

アップデート:

コードでビューを手動で追加すると、機能します。しかし、Interface Builder でアウトレットとして作成した UIView では機能しません。

UILabel *testLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 100.0)];
testLabel.backgroundColor = [UIColor redColor];

[self.view addSubview:testLabel];

[UIView animateWithDuration:3.0 animations:^{
    testLabel.center = CGPointMake(0.0, 200);
}];

だから明らかに私は.xibファイルで何か間違ったことをしています

4

2 に答える 2

2

viewDidLoad では行わないでください。その時点ではまだビューは差し迫っていません。viewDidAppear で試してみてください。

于 2012-10-04T10:23:09.747 に答える
0

アニメーションが欠落している理由は、実際のビューを画面にプッシュしていたビュー コントローラーとは別のプッシュ ナビゲーション アニメーションを呼び出したことが原因だと思います。

- (IBAction)goForSelection:(id)sender
{
    SelectionViewController *selectionViewController = [[SelectionViewController alloc] initWithNibName:@"SelectionViewController" bundle:nil];

    //[self.navigationController pushViewController:selectionViewController animated:YES];

    [UIView transitionWithView:self.navigationController.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
        [self.navigationController pushViewController:selectionViewController animated:NO];
    } completion:^(BOOL finished) {
        [selectionViewController startIntroAnimation];
    }];
}

最初に、デフォルトのナビゲーション コントローラー セグエを使用するとどうなるかを確認しました。そして驚いたことに、アニメーションが始まりました。[selectionViewController startIntroAnimation]次に、完了ブロックへの呼び出しを挿入しましたが、これも機能します。

于 2012-10-04T16:04:09.090 に答える