如何在 iOS 的 Quick Look 工具栏中添加自定义按钮?

发布于 2024-10-28 01:16:54 字数 200 浏览 2 评论 0原文

我目前正在 iPad 上通过模态视图控制器使用 Quick Look 框架显示 PDF 文件。效果很好。我的问题是,由于我正在显示 PDF 文件,“快速查看”预览会自动添加“打印”按钮。我想做的是将“打印”按钮替换为自定义“电子邮件”按钮。这是可以做的事情吗?起初,我认为这将是一件微不足道的事情,但此时我真的很挣扎。任何帮助将不胜感激。

谢谢,

布雷特

I'm currently displaying a PDF file using the Quick Look framework on an iPad via the Modal View Controller. Works great. My problem is that since I'm displaying a PDF file the Quick Look preview is automatically adding a "Print" button. What I would like to do is replace the "Print" button with a custom "Email" button. Is this something that can be done? At first pass I thought this was going to be a somewhat trivial thing to do but at this point I'm really struggling with it. Any help would be greatly appreciated.

Thanks,

Brett

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

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

发布评论

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

评论(2

清晰传感 2024-11-04 01:16:54

由于QLPreviewController是UIViewController的子类,因此您可以利用-[UIViewController setToolbarItems:]来自定义工具栏。

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(emailPDF)]; 
NSArray *items = [NSArray arrayWithObject:item];
[previewController setToolbarItems:items animated:NO];   
[[self navigationController] presentModalViewController:previewController animated:YES];

现在,当用户点击工具栏中的“回复”图标时,将调用您的 -emailPDF 实现。

Since QLPreviewController is a subclass of UIViewController, you can take advantage of -[UIViewController setToolbarItems:] to customize the toolbar.

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(emailPDF)]; 
NSArray *items = [NSArray arrayWithObject:item];
[previewController setToolbarItems:items animated:NO];   
[[self navigationController] presentModalViewController:previewController animated:YES];

Now when the user taps the "reply" icon in the toolbar, your implementation of -emailPDF will get called.

暖树树初阳… 2024-11-04 01:16:54

您可以创建 QLPreviewController 的子类,例如 MyQLPreviewController

然后在 viewWillAppear:(BOOL)animated (重要!!)

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIBarButtonItem *rightRatain = self.navigationItem.rightBarButtonItem;
    UIBarButtonItem *email = ...;

    self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:right, email, nil];
    [email release];
}

you can create a subclass of QLPreviewController like MyQLPreviewController

Then in viewWillAppear:(BOOL)animated (IMPORTANT!!)

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIBarButtonItem *rightRatain = self.navigationItem.rightBarButtonItem;
    UIBarButtonItem *email = ...;

    self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:right, email, nil];
    [email release];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文