HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – QLPreviewController删除或添加UIBarButtonItems大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在互联网上看到这样的问题,但似乎没有人真的知道答案?

我正在使用QLPreviewController显示PDF文档。我首先使用了一个UIWebView,但是由于性能上的原因,我建议使用QLPreviewController来更大的文档。

我想要的是4个自定义UIBarButtonItem在右上方(所以打印按钮在哪里)。

我设法在底部获得一个自定义工具栏,但这并不是我想要的。

虑到无法在打印按钮的地方添加自定义按钮,我仍然希望删除打印按钮,并使用自定义工具栏。

编辑(解决方案):
之前我找到了解决方案,但没有更新这篇文章,所以这里是我如何解决问题:

我手动添加按钮:

// Create a toolbar to have the buttons at the right side of the navigationBar
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,180,44.01)];
[toolbar setTranslucent:YES];

// Create the array to hold the buttons,which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:4];


// Create button 1
button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@SELEctor(button1Pressed)];
[buttons addObject:button1];

// Create button 2
button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@SELEctor(button2Pressed)];
[buttons addObject:button2];

// Create button 3
button3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@SELEctor(button3Pressed)];
[buttons addObject:button3];

// Create a action button
openButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@SELEctor(openWith)];
[buttons addObject:openButton];

// insert the buttons in the toolbar
[toolbar setItems:buttons animated:NO];

// and put the toolbar in the navigation bar
[[self navigationItem] setrightBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:toolbar]];

解决方法

更新:

这不再适用于iOS 6. Quick Look在使用XPC的另一个进程中运行。详见here。我没有预见任何方式来定制QLPreviewController。对于iOS 6之前的任何人来说,以下答案仍然存在。

我回答了一天几乎相同的问题here.这个问题涉及到删除打印按钮,这不是太难了。有一件事要注意的是,QLPreviewController是不是要定制。我已经建立了一个可以自定义的QLPreviewController子类。我把它here放在Github上。它的设计也很容易删除动作按钮,以及其他功能。用自定义按钮替换按钮不会花费太多的精力。

要注意的最大的一件事是,当显示新文档时,操作按钮将重新添加到导航栏中。你应该注意到我的代码。随时RBFilePreviewer删除操作按钮,您只需要重新添加自定义按钮。要添加自定义按钮,您应该创建一个UIBarButtonItem,其中包含四个按钮的自定义视图。然后将右侧的按钮项设置为您创建的自定义UIBarButtonItem。

更新:

我更新了RBFilePreviewer以允许您立即开始设置一个自定义的右键菜单项。只需调用-setrightBarButtonItem:在RBFilePreviewer,它只是工作。

大佬总结

以上是大佬教程为你收集整理的iphone – QLPreviewController删除或添加UIBarButtonItems全部内容,希望文章能够帮你解决iphone – QLPreviewController删除或添加UIBarButtonItems所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。