2

現在でメソッドを実行していて、現在実行中のメソッドの最後に到達しCurrentViewControllerたら、自分FirstViewController(移動先のViewControllerの実際の名前)に移動したい

CurrentViewController.m

-(void)methodExecutingOnCurrentViewController
{
    //some code..

    // what method do I call in order to load and move to my FirstViewController at this point?

    // do I first initialize an instance of the ViewController I want to move to?
    UIViewController *firstViewController = [[FirstViewController alloc] init];


    // but now how do I actually move to this instance I've just created? 
    // I couldn't find the appropriate method in the class reference documentation

}
4

4 に答える 4

1

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animatedDocを見てください。

あなたが探していることを達成することができる他の多くの方法があります、あなたはナビゲーションコントローラーを使用していますか?次に- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated、あなたが望むものです。そのコントローラーのビューをサブビューとして現在のviewControllerに追加することもできます。

于 2012-09-04T23:42:57.760 に答える
1

UINavigationControllerを使用している場合(使用していない場合はそうする必要があります)、次のように実行できます。

[self.navigationController.pushViewController pushViewController: firstViewController animated:YES];

これにより、ViewControllerがナビゲーションスタックにプッシュされます。

ビューコントローラをモーダルに表示することもできます。ここでそれについて読んで、自分に最適なものを決定する必要があります。

于 2012-09-04T23:43:21.253 に答える
1

プロジェクトをナビゲーションコントローラーに基づいて、プッシュするだけです

SecondViewController * secondVC = [[SecondViewController alloc] init];

     [self.navigationController secondVC animated:YES];
于 2012-09-04T23:45:08.770 に答える
0

UINavigationControllerを使用しない場合は、次の方法で他のUIViewcontrollerに移動できます。

NewViewController *newVC = [[NewViewController alloc] init];
[self dismissViewControllerAnimated:YES completion:^{[self presentViewController:newVC animated:YES completion:^{}];}];
于 2014-11-17T07:47:00.087 に答える