10

Obj-CまたはMonoTouch C#答えは大丈夫です。

最初の UIWindow の RootViewController は単純なログイン画面です。

window.RootViewController = loginScreen;

ログイン後、ルートをメインアプリに設定します

window.RootViewController = theAppScreen;

このインスタンスで 2 つの RootViewController 間のフェード遷移を行うにはどうすればよいですか?

4

3 に答える 3

19

あなたのアニメーションを得る別のアプローチを提案するかもしれません。最初theAppScreenにコントローラーに移動し、ユーザーがログインする必要がある場合は、コントローラーに を実行させます(ログイン画面に直接移動したように見せたい場合は、このステップをアニメーション化する必要はありません)。そうすれば、ログインに成功すると、loginScreen ができて、アニメーションを main に戻すことができます。(明らかに、フェード効果が必要な場合は、コントローラーをに設定することを忘れないでください。)presentViewControllerloginScreendismissViewControllerAnimatedtheAppScreenmodalTransitionStyleUIModalTransitionStyleCrossDissolve

あなたがあなたrootViewControllerの .

MainAppViewController *controller = [[MainAppViewController alloc] initWithNibName:@"MainAppViewController" bundle:nil];

// animate the modal presentation

controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self.window.rootViewController presentViewController:controller 
                                             animated:YES
                                           completion:^{

    // and then get rid of it as a modal

    [controller dismissViewControllerAnimated:NO completion:nil];

    // and set it as your rootview controller

    self.window.rootViewController = controller;
}];

最初のテクニックは、私にはずっときれいに思えます。

于 2012-07-28T01:23:18.687 に答える
3

これは @Robert Ryan の手法の MT コードです (ただし、theAppScreenおそらく「正しい」という彼の提案には同意しますRootViewController):

void DissolveIn (UIWindow window, UIViewController newController)
{
  newController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
  window.RootViewController.PresentViewController (newController, true, () => 
  {
    window.RootViewController.DismissViewController (false, null);
    window.RootViewController = newController;
  });
}
于 2012-07-28T02:02:46.873 に答える
1

あなたはこれを行うことができます:

window.RootViewController = theAppScreen;

loginScreen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[theAppScreen presentModalViewController:loginScreen animated:NO];

完了したら loginScreen 自体を閉じることができます。[self dismissModalViewControllerAnimated:YES];

最初のアニメーションの NO は、その下にある theAppScreen を表示せずに loginScreen を表示します。完了時のアニメーション = YES は、クロス ディゾルブを提供します。

于 2012-07-28T01:31:34.453 に答える