0

最初のView Controllerとして4 がViewControllersあります。startViewControllerこれには私のイントロが含まれています。その終了後、それは[self presentViewController:vc animated:YES completion:NULL];私のmenuViewController.


startViewController ------> menuViewController ------> C1ViewController
                                          \
                                           \ ------> ImportantViewController

私の中には上のイラストのようなmenuViewController2つのボタンがあります。ViewControllerまた、私はこれでビューにそれらを提示しました:[self presentViewController:vc animated:YES completion:NULL];私はこれで戻りmenuViewControllerます[self dismissModalViewControllerAnimated:YES];

私が欲しかったのは、ImportantViewController他のビューに行っても、親ビューまたはメインビューのようにすることです。私が必要とするImportantViewControllerのは、私が行くときに がいつ提示されるかC1ViewControllermenuViewController割り当てが解除されないか、そこにあるコンテンツが保持されるかです。

出来ますか?そしてどうやって?

親と子のView Controllerの目的についてあまり知らないので、問題に何を実装すればよいかわかりません。ありがとうございました。

ところで、ストーリーボードを使用しています。

4

2 に答える 2

0

ImportantViewControllerのルート ビューを作成し、ImportantViewControllerUINavigationControllerの代わりに を提示します。UINavigationController

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:YourImportantViewControllerOBject];

//insted of presentModalViewControlle with YourImportantViewControllerOBject you do
[self presentModalViewController:navigationController animated:YES];

ImportantViewController で新しいView Controllerを提示するには、次のことを行います

[self.navigationController pushViewController:yourC1ViewController animated:YES];
于 2012-07-01T15:21:07.817 に答える
0

私はあなたが何をしたいのかについて 100% ではありませんが、ARC を使用している場合、ImportantViewController を __strong に設定すると保持されます。ImprotantViewController.m で必要なビュー コントローラーをプログラムで作成して、ImportantViewController を親にしないのはなぜですか?

// ImportantViewController.m
// non ARC
FirstChildViewController *firstChild = [[FirstChildViewController alloc] initWithNib@"FirstChildViewController" bundle:nil];

//set firstChild.view position here if needed. e.g. .center = CGPointMake(x,y);

//now add firstChild to the parent
[self addSubview:firstChild];
[firstChild release];

2 番目のビューまたは任意の数のビューで同じことができます。これは、View Controller を提示するよりも優れていると思います。コア アニメーションを子ビューに追加して、優れた UI を作成することもできます。

この回答はお役に立ちましたか?多分私はあなたが望んでいたものを正確に得られませんでした. :)

于 2012-07-01T15:18:39.317 に答える