5

ビュー コントローラーを別のビュー コントローラーにプッシュする必要があります。

menuVC -> VC1 ->VC2

menuVC から VC1 への移行にはアニメーションは必要ありませんが、VC1 から VC2 および VC2 から VC1 への移行にはフリップ アニメーションが発生する必要があります。

ただし、VC2 から menuVC に移行する場合、アニメーションは必要ありません。

次のコードを使用しています。

フリップアニメーションでviewControllerをプッシュする方法から

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
FlashCardVC *flashCardVC = [[FlashCardVC alloc] init];
[self.navigationController pushViewController:flashCardVC animated:NO];
[UIView commitAnimations];

上記を実行しようとすると、画面が完全に空白になります。

なにが問題ですか?

4

3 に答える 3

18

ブロックベースのアニメーションを使用する必要があります。また、同じストーリーボードにあるコントローラーからストーリーボード コントローラーをインスタンス化する場合は、self.storyboard を使用してそのストーリーボードに簡単にアクセスできます。

-(IBAction)flipToNext:(id)sender {
    SecondController *next = [self.storyboard instantiateViewControllerWithIdentifier:@"Next"];
    [self.navigationController pushViewController:next animated:NO];
    [UIView transitionWithView:self.navigationController.view duration:1 options:UIViewAnimationOptionTransitionFlipFromRight animations:nil completion:nil];
}
于 2013-02-10T16:37:17.193 に答える
1

すばらしい回答: pushviewcontrollerアニメーションを表示するとpresentModalViewControllerのようになります

(コード)

    //UIViewController *yourViewController = [[UIViewController alloc]init];</s>

    [UIView  beginAnimations: @"Showinfo"context: nil];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController: yourViewController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];

ただし、これにより空白の画面も生成されました。

代わりに、ストーリーボードを使用している場合は、ストーリーボードを介してインスタンス化するのが最適です。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle bundleForClass:[self class]]];

YourViewController *yourViewController = [storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];

yourViewControllerIDは、ストーリーボードのyourviewcontrollerクラスのIDインスペクターの下に設定されます。

于 2013-02-10T12:18:03.837 に答える