开发者

modal UINavigationController inside UIPopoverViewController

开发者 https://www.devze.com 2023-04-03 08:20 出处:网络
This is my situation: I have a UINavigationViewController (with a stack of UITableViewControllers) which is inside an UIPopoverViewController. This is how it looks now:

This is my situation:

I have a UINavigationViewController (with a stack of UITableViewControllers) which is inside an UIPopoverViewController. This is how it looks now:

modal UINavigationController inside UIPopoverViewController

Then one of the buttons there have this action:

MyViewController *moveViewcontroller = [[MyViewController alloc] init];
moveViewcontroller.contentSizeForViewInPopover = self.contentSizeForViewInPopover;

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:moveViewcontroller];
navController.toolbarHidden = NO;
navController.navigationBarHidden = NO;
navController.contentSizeForViewInP开发者_Python百科opover = self.navigationController.contentSizeForViewInPopover;
navController.modalPresentationStyle = UIModalPresentationCurrentContext;//to show it inside the popover

[self.navigationController presentModalViewController:navController animated:YES];
[navController release];
[moveViewcontroller release];

Which shows the navigation controller but it not embedded in the `UIPopoverController like the navigation controller in the first picture. This is what I get:

modal UINavigationController inside UIPopoverViewController

Not very nice and it is not consistent with the previous interface Is there a way I can make my modal navigation controller be embedded in the UIPopoverController?

Basically, I want to implement a similar interface as in Mail.app in the iPhone (when moving emails from one folder to another) but inside a popover.


You need to specify the presentation style for the UIViewController you are presenting in a modal way. I do this using the following code:

MyViewController* mvc = 
[[MyViewController alloc]
 initWithNibName:@"MyViewController"
 bundle:nil];
mvc.modalPresentationStyle = UIModalPresentationFormSheet;
mvc.contentSizeForViewInPopover = CGSizeMake(320.0f, 210.0f);
[self.navigationController pushViewController:mvc animated:YES];

The key line is the one dealing with the modalPresentationStyle - which forces the modal view controller to appear inside the UIPopoverController

0

精彩评论

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