6

1 つのモーダル ビュー コントローラーを閉じてから、すぐに別のモーダル ビュー コントローラーを提示していますが、現在、2 つ目のモーダル ビュー コントローラーだけでアニメーションを使用することはできません。

ユーザーが両方のアニメーションを体験できるように、プロセスを遅らせる方法はありますか?

以下のコードは現在動作しますが、明らかに 2 番目のアニメーションしか表示されません。

// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
[self presentModalViewController:detailViewController animated:YES];

//Dismiss first one
[self dismissModalViewControllerAnimated:NO]; 

//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];
4

4 に答える 4

9

現在のモーダル ビュー コントローラーで使用できる完了ブロックが追加されました。このリンクを参照してください。iOS5.0以降でご利用いただけます。

これには、タイマー ソリューションを使用する場合にタイマーの遅延を見積もる必要がないという利点があります。

2 番目のアニメーションのコードをブロックに入れるだけです。

//Block safe reference to self to prevent retain cycles
__block typeof (self) selfReference = self;

// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
[self presentModalViewController:detailViewController animated:YES completion:
^{
    //Dismiss first one
    [selfReference dismissModalViewControllerAnimated:NO]; 

    //Immediately configure and show second one
    navController.modalPresentationStyle = UIModalPresentationFormSheet;
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [selfReference presentModalViewController:navController animated:YES];
 }];
于 2012-05-24T10:39:48.480 に答える
1

あなたは他のスタイルでそれを行うことができます。

detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
[self presentModalViewController:detailViewController animated:YES];

[self dismissModalViewControllerAnimated:NO]; 

[self performSelector:@selector(someFunction) withObject:nil afterDelay:1.0];

- (void) someFunction{
//Immediately configure and show second one
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];

}

于 2012-05-24T10:41:03.800 に答える
1

これで試してください:

// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
[self presentModalViewController:detailViewController animated:YES];

//Dismiss first one
[self dismissModalViewControllerAnimated:NO]; 
NSTimer Timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(openSecondView) userInfo:nil repeats:NO];


-(void)openSecondView
{
    //Immediately configure and show second one
    navController.modalPresentationStyle = UIModalPresentationFormSheet;
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navController animated:YES];
}

ハッピーコーディング...

于 2012-05-24T10:41:32.000 に答える
1

次のことを行うセレクターを作成します。

- (void)showSecondModalVC {
  //Dismiss first one
  [self dismissModalViewControllerAnimated:NO]; 

  //Immediately configure and show second one
  navController.modalPresentationStyle = UIModalPresentationFormSheet;
  navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  [self presentModalViewController:navController animated:YES];
}

次に、コードのメイン部分に次のように記述します。

// First one configure
detailViewController.modalPresentationStyle = UIModalPresentationFullScreen;
detailViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
[self presentModalViewController:detailViewController animated:YES];

[self performSelector:@selector(showSecondModalVC) 
         withObject:nil 
         afterDelay:0.5f];

アニメーションが見栄えがするように、最初のモーダルが表示されるまでにどれくらいかかるかをよく見て確認する必要があります。

于 2012-05-24T10:38:48.400 に答える