我的问题类似于这个 question > ,其中 OP 的目标是将 UIBarButtonItems 数组显示为 navigationItem.rightBarButtonItems,而没有 barbuttons 的轮廓/边框。他的解决方案,使用 UIButton 自定义 View 初始化 UIBarButtonItem,给出了所需的外观,并且 UIButton 目标/操作模式适用于调用方法,但不适用于定位 UIPopoverController。我想要做的是在弹出窗口中展示一个 actionSheet(即在 iPad 上展示一个 actionSheet),并且(从不同的按钮)展示一个打印 Controller 弹出窗口,弹出窗口箭头指向所选的栏按钮,作为 rightBarButton iPad 邮件应用程序中的项目。问题是,用于呈现 actionSheet 或 popover 的方法:[UIActionSheet showFromBarButtonItem:bbtn animated:YES];或者[UIPrintInteractionController presentFromBarButtonItem:printButton animated:YES completionHandler:completionHandler]使用 UIButton 发送者调用时不起作用。此外,从 CGRect 呈现的方法,例如[controller presentFromRect:rect inView:self.view animated:YES completionHandler:completionHandler]不要正确定位 popover 指针。我尝试使用 UIView convertRect:toView: 转换按钮框架并从转换后的矩形显示弹出框,但我要么做错了,要么无法从没有框架属性的 UIBarButtonItem super View 正确转换。显示了弹出框,但弹出框箭头未指向所选按钮。 最佳答案 尝试在导航 Controller 的 View 坐标中计算转换后的按钮框架。例如。CGRect convertedRect = [self.navigationController.view convertRect:button.bounds fromView:button];[controller presentFromRect:convertedRect inView:self.navigationController.view animated:YES completionHandler:completionHandler];关于ipad - 在 iPad 上使用自定义 View 从 UIBarbuttonItems 呈现弹出窗口,就像在邮件应用程序中一样?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14086632/
10-16 17:18