3
UIImageView * frontImageView = [[UIImageView alloc] initWithImage:[UIImage 
                                                                   imageNamed:@"view.png"]];

UIView * containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = self.view.center;

[self.view addSubview:containerView];
[containerView addSubview:frontImageView];

UIImageView * backImageView = [[UIImageView alloc] initWithImage:[UIImage 
                                                                  imageNamed:@"view.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                       forView:containerView 
                         cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];

containerView を反転させたいのですが、うまくいきません。

4

3 に答える 3

2

これは、同じ問題に関する同様の投稿です。@Jason Harwig は、次のことを試すことを提案しています。

self.view.superviewのアニメーション遷移ビューで 使用してみてくださいshowMoreInfo:

編集:別の投稿を見ると、アニメーションをコミットする前にサブビューを追加することが問題のようですやってみませんか?

それが役立つことを願っています!

于 2011-09-06T06:54:35.403 に答える
0

containerViewのフレームを正しく設定します。正しくないfrontImageView.boundsに設定しました。

于 2011-09-06T07:06:20.527 に答える
0

使用しないでください

[frontImageView removeFromSuperview];

この機能で。アニメーションが発生する前に、ビューがスーパービューから削除されます。したがって、アニメーションはありません。代わりにこれを使用します。

[UIView setAnimationDidStopSelector:@selector(removeImageView)];

別の方法を作り、

-(void) removeImageView
{
        if([yourImageView superview])
            [yourImageView removeFromSuperview];
}
于 2011-09-06T06:54:40.470 に答える