开发者

What Type of ViewController To Make?

I have a button that when pressed, brings up a modal view.

Lets call this modal view "AboutViewController".

My question is, what type of viewController should this be. I set up the rest of my app a while ago and don't remember exactly how I got it setup.

I already have a TabBar that is present so Ill ju开发者_如何学Pythonst make it viewable at the bottom, that shouldn't be an issue.

But I want it to be a navController but I want it to be separate from the nav stack of the rest of my app, I will then add a UITable, etc in IB.


You can add that view as a PresentModalViewController. You have to add that view as same as we are adding the other view in our project.

And then after when button is pressed you have to write below code to show that view.

AboutViewController *aboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
[self presentModalViewController:aboutViewController animated:YES];
[aboutViewController release];


Just do:

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:AboutViewController];
[self presentModalViewController:nav animated:YES]; 


I assume you have a class for the Modal View? Say you called it AboutViewController.

You would just need to do:

    AboutViewController *viewController = [[AboutViewController alloc] init];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    [viewController release];

    [self presentModalViewController:navController animated:YES];
    [navController release];

The nav stack for the Modal View will be separate from your other nav stack and your Modal View Controller will handle it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜