UIPopoverViewController 内的模态 UINavigationController

发布于 2024-12-03 07:47:36 字数 1432 浏览 4 评论 0原文

这是我的情况:

我有一个 UINavigationViewController (带有一堆 UITableViewControllers),它位于 UIPopoverViewController 内。这是现在的样子:

然后其中一个按钮具有以下操作:

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

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:moveViewcontroller];
navController.toolbarHidden = NO;
navController.navigationBarHidden = NO;
navController.contentSizeForViewInPopover = self.navigationController.contentSizeForViewInPopover;
navController.modalPresentationStyle = UIModalPresentationCurrentContext;//to show it inside the popover

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

它显示导航控制器,但它不像第一张图片中的导航控制器那样嵌入在`UIPopoverController中。这就是我得到的:

不太好看,和之前的界面不太一致 有没有办法让我的模态导航控制器嵌入 UIPopoverController

基本上,我想实现一个与 iPhone 中的 Mail.app 类似的界面(当将电子邮件从一个文件夹移动到另一个文件夹时),但在弹出窗口内。

This is my situation:

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

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.contentSizeForViewInPopover = 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:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黑寡妇 2024-12-10 07:47:36

您需要为以模态方式呈现的 UIViewController 指定呈现样式。
我使用以下代码执行此操作:

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

关键行是处理 modalPresentationStyle 的行 - 它强制模式视图控制器出现在 UIPopoverController 内

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文