gpt4 book ai didi

objective-c - 顶部的 UIPopoverController 工具栏

转载 作者:太空狗 更新时间:2023-10-30 03:48:42 24 4
gpt4 key购买 nike

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

enter image description here

我已经设法使用与 this post 中描述的相同方法将一个放在底部但我无法将其移至顶部。

我可以通过在其中一个 subview Controller 中放置一个普通的 UIToolbar 来做到这一点,但是工具栏似乎与边框不在同一条线上,而且看起来不像在苹果应用程序中那样漂亮。

有没有人对如何执行此操作有任何建议,或者是否可能?任何帮助将不胜感激。

谢谢!

最佳答案

使用一个 UINavigationController,它只包含一个 ViewController 作为 popoverController 的内容,像这样:

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 的初始化中,设置 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,您的导航 Controller 将不会导航。

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

关于objective-c - 顶部的 UIPopoverController 工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6599918/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com