我在互联网上看到了很多这样的问题,但似乎没有人真的知道答案?QLPreviewController删除或添加UIBarButtonItems
我正在使用QLPreviewController来显示PDF文档。我首先使用了一个UIWebView,但我建议使用QLPreviewController来代替性能较高的文档。
我想要的是4个自定义的UIBarButtonItem的在右上角(所以在哪里打印按钮)。
我设法得到一个自定义工具栏在底部,但那不是我想要的。
考虑到无法在打印按钮的位置添加自定义按钮,我仍然想要删除打印按钮并使用自定义工具栏。
EDIT(解决方案): 我找到了解决办法前一段时间,但没有更新这个帖子所以这里是我如何解决了这个问题:
我加人手动按钮:
// Create a toolbar to have the buttons at the right side of the navigationBar
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 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]];
RBFilePreviewer现在支持您正在查找的功能,无需修改。 – rbrown
我的回答是否足以被接受和赏金? – rbrown
这不是真的,我正在寻找,我现在有QLPreviewController的其他问题:http://stackoverflow.com/questions/7038438/quicklook-not-showing-offline-files但我会除了你的答案因为它是最好的(也是唯一的),它对我有一点帮助。 – Justin