1

非常に単純なフリップ アニメーションを実装していますが、フリップがありません。

私はドキュメントの例をテンプレートとして使用しています.Appleは現在、アニメーションにブロックを使用することを推奨しており、これが取るべきアプローチです:(ドキュメントから)

[UIView transitionWithView:containerView
           duration:0.2
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
           completion:NULL]; 

遷移する 2 つのビューをコンテナーにラップします。私はこのようにします。

UIView *container = [[UIView alloc] initWithFrame:target];
[self.view addSubview:container];
[container addSubview:productImage];

UIView *background = [[UIView alloc] initWithFrame:target];
[background setBackgroundColor:[UIColor darkGrayColor]];
[background setAlpha:0.1f];

[UIView transitionWithView:container
                  duration:0.8
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations:^{ 
                    [[[container subviews] objectAtIndex:0] removeFromSuperview];
                    [container addSubview:background]; 
                }
                completion:NULL];

2 つの奇妙なことが起こります。トランジションはありません。コンテナは productImage (UIImageView タイプ) を表示し、それを背景ビューと交換します。アニメーションなし。

2 番目のことは、これが通常のタイプミスではないと私が信じるに至った理由です。

UIViewAnimationOptionTransitionFlipFromRight

Xcode によって認識されず、オートコンプリートされず、強調表示されません。Xcode は、廃止されたものを使用する場合にのみそれを行います。

UIViewAnimationTransitionFlipFromRight //i.e. without the Option part

次に、SDK のバージョンなどを確認し始めました。すべてが 4.2 に設定されているようです。XCode はバージョン 3.2.5 で、ターゲットとプロジェクトの両方の設定でビルドとデプロイのターゲットが 4.2 に設定されています。

ここで何が欠けていますか?

訓練された目が私を助けてくれることを願っています:)事前に感謝します。

4

2 に答える 2

-1

このコードはあなたを助けるでしょう

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];


UIViewAnimationTransition transition = UIViewAnimationTransitionFlipFromRight;
[UIView setAnimationTransition:transition forView:[self.navigationController view] cache:NO];


[UIView commitAnimations];

乾杯

于 2011-01-13T13:05:40.390 に答える