在UIPopoverController中自定义titleView

Lee*_*Lee 7 uinavigationcontroller ipad uipopovercontroller ios

在iPad应用程序上,我希望能够在弹出窗口的顶部栏中有多个按钮.我这样推出它:

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];

pop = [[UIPopoverController alloc] initWithContentViewController:nc];
[pop presentPopoverFromRect:CGRectInset([tableView rectForRowAtIndexPath:indexPath], 10, 10)
                     inView:tableView
   permittedArrowDirections:UIPopoverArrowDirectionAny
                   animated:YES];
pop.delegate = self;
[nc release];
Run Code Online (Sandbox Code Playgroud)

viewDidLoad我想设置titleView包含多个UIBarButtonItems.这是正常的,UINavigationController但我需要能够执行此操作并在弹出框中保留导航栏的自定义样式.

我试过设置rightBarButtonItem一个包含按钮的工具栏,但它们采用工具栏的格式,它本身不会采用弹出窗口的格式/样式.

Ben*_*ayo 1

这有点hackish,但是您可以通过使用空方法子类化和覆盖drawRect:来创建真正透明的UIToolbar。这仍然会在工具栏上绘制 UIBarButtonItems,但不会绘制工具栏本身。

然后,正如 Nils 所描述的,您可以从自定义工具栏实例中创建一个栏按钮项目并将其添加为 rightBarButtonItem。