8

アニメーションの完了後にコードのブロックを実行したいのですが、コンパイラに次のエラーが表示されます。

これが私のコードです。何が間違っているのかわかりません。助けてください、ありがとう。

[UIView transitionWithView:self.view duration:1.5
                   options:UIViewAnimationOptionTransitionFlipFromBottom //change to whatever animation you like
                animations:^ {
                    [self.view addSubview:myImageView1];
                    [self.view addSubview:myImageView2];
                }
                completion:^ {
                    NSLog(@"Animations completed.");
                    // do something...
                }];
4

1 に答える 1

14

ブロックタイプが間違っているだけです:)以下のようなブロックが必要です。鍵となるのは^(BOOL finished) {...}

[UIView transitionWithView:self.view duration:1.5
                   options:UIViewAnimationOptionTransitionFlipFromBottom //change to whatever animation you like
                animations:^ {
                    [self.view addSubview:myImageView1];
                    [self.view addSubview:myImageView2];
                }
                completion:^(BOOL finished){
                    if (finished) {
                        // Successful
                    }
                    NSLog(@"Animations completed.");
                    // do something...
                }];
于 2013-01-18T19:41:09.550 に答える