顶部的 UIPopoverController 工具栏

发布于 2024-11-18 12:55:33 字数 480 浏览 8 评论 0原文

我试图将 UIToolbar 放置在 UIPopoverController 的顶部,就像 Apple 在页面和主题演讲中使用“媒体”、“表格”、“图表”“形状”工具栏所做的那样。

在此处输入图像描述

我已设法使用与 这篇文章但我无法将其移至顶部。

我可以通过在子视图控制器之一中放置一个普通的 UIToolbar 来做到这一点,但是工具栏似乎并不遵循与边框相同的线,并且看起来不像在苹果应用程序中那么漂亮。

有没有人对如何做到这一点有任何建议,或者是否可能?任何帮助将不胜感激。

谢谢!

I am trying to place a UIToolbar at the top of a UIPopoverController in much the same way as Apple have done in pages and keynote with the "media", "tables", "charts" "shapes" toolbar.

enter image description here

I've managed to place one at the bottom using the same method described as in this post but I'm unable to move it to the top.

I can do it by just placing a normal UIToolbar within one of the child view controllers however the toolbar does not seem to follow the same line as the border and doesn't look as nice as it does in the apple apps.

Does anyone have any suggestions on how to do this, or if it's even possible? Any help would be much appreciated.

Thanks!

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

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

发布评论

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

评论(2

听风吹 2024-11-25 12:55:33

使用只包含一个 ViewController 作为 popoverController 内容的 UINavigationController,如下所示:

MyViewController *myVC = [[myViewController alloc] init];

UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:myVC];

myPopoverController = [[UIPopoverController alloc] initWithContentViewController:navCon];

[myVC release];
[navCon release];

[myPopoverController presentPopoverFromRect:rect
                                     inView:view
                   permittedArrowDirections:UIPopoverArrowDirectionRight
                                   animated:YES];

然后,在 viewController 的 init 中,设置 navigationController 的项目:

self.navigationItem.title = @"myTitle";
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonTapped:)] autorelease];

你可以疯狂地把你想要的任何东西放在那里:

self.navigationItem.titleView = [[MySpecialTitleView alloc] initWithFrame...];

如果满足以下条件,你的导航控制器将不会进行导航:它的堆栈上只有一个 ViewController。

iOS 7 警告:弹出窗口内的导航栏似乎忽略了 iOS 7 中的色调。我认为这是一个错误,如果您遇到此问题,鼓励您向 Apple 提交错误报告。

Use a UINavigationController that holds just your one ViewController as the popoverController's content, like so:

MyViewController *myVC = [[myViewController alloc] init];

UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:myVC];

myPopoverController = [[UIPopoverController alloc] initWithContentViewController:navCon];

[myVC release];
[navCon release];

[myPopoverController presentPopoverFromRect:rect
                                     inView:view
                   permittedArrowDirections:UIPopoverArrowDirectionRight
                                   animated:YES];

Then, in your viewController's init, set the navigationController's items:

self.navigationItem.title = @"myTitle";
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonTapped:)] autorelease];

You can go crazy and put whatever you want in there:

self.navigationItem.titleView = [[MySpecialTitleView alloc] initWithFrame...];

Your navigation controller won't be navigating if there is only one ViewController on its stack.

iOS 7 caveat: NavigationBars inside popovers seem to ignore tint in iOS 7. I think that's a bug and encourage you to file a bug report with apple if you encounter this issue.

墟烟 2024-11-25 12:55:33

您可以将工具栏放在 UIPopoverController 之上。

更准确地说,您必须将其放在 UIViewController 之上,在调用 initWithContentViewController 时将其设置为 UIPopoverController 的内容。

如果您使用IB:
1) 将 UItoolbar 拖到 UIViewController 的顶部
2) 选择 UIToolbar,转到尺寸检查器并在自动调整大小部分:
- 单击顶部指示器来修复上边距
- 单击底部指示器以使底部边距灵活

在小预览窗口中,红色条应保留在顶部

You can put a toolbar on top of your UIPopoverController.

More precisely you have to put it on top of the UIViewController that will be set as the content of your UIPopoverController when calling initWithContentViewController.

If you are using IB:
1) drag a UItoolbar to the top of your UIViewController
2) select the UIToolbar, go to the size inspector and in the autosizing section:
- click on the top indicator to fix the top margin
- click on the bottom indicator to make the bottom margin flexible

In the little preview window the red bar should stay on top

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