UIDocumentInteractionController删除操作菜单 [英] UIDocumentInteractionController remove Actions Menu

查看:79
本文介绍了UIDocumentInteractionController删除操作菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Apple示例代码从这里查看文档:

理想情况下,我想将所有按钮全部删除,但是如果我可以禁用它或禁用其中的所有选项,也就足够了.我发现了这个问题:

在+ UIDocumentInteractionController中打开:如何SDK iOS 6中的过滤器选项(不建议使用canPerformActions)

但是我不知道如何使用建议禁用菜单中的选项.我已经在这里上传了修改后的示例代码:

http://plasma.servebeer.com/DocSampleCode.zip

最后一点要注意的是,这将不会在App Store上发布,而是供私人使用,因此,如果有一种非官方的方式,那么我也很想知道这一点.

任何帮助将不胜感激,在此先感谢.

等离子

解决方案

使用 UINavigationControllerDelegate

  @interface DITableViewController()< UIDocumentInteractionControllerDelegate,UINavigationControllerDelegate> 

将navigationController委托分配给自己

 -(void)viewDidLoad {[super viewDidLoad];self.navigationController.delegate =自我;} 

更改 documentInteractionControllerViewControllerForPreview

 -(UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)interactionController {返回self.navigationController;} 

添加此 UINavigationControllerDelegate 方法

 //当导航控制器通过推,弹出或设置视图控制器堆栈显示新的顶视图控制器时调用.-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController动画:(BOOL)动画{如果([viewController isKindOfClass:[QLPreviewController类]]){viewController.navigationItem.rightBarButtonItem = nil;}} 

更新MP4文件

在MP4文件中,操作按钮位于 UIToolbar

 -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController动画:(BOOL)animated {如果([viewController isKindOfClass:[QLPreviewController类]]){viewController.navigationItem.rightBarButtonItem.customView = [[UIView alloc] init];UIBarButtonItem * item = viewController.toolbarItems.firstObject;item.customView = [[UIView alloc] init];}} 

这可能在将来的iOS版本中不起作用

I've been working with the Apple sample code for viewing documents from here:

https://developer.apple.com/library/ios/samplecode/DocInteraction/Listings/ReadMe_txt.html

I have removed all the bits I don't need and got it working pretty much how I would like it to. The problem is I don't want users to have access to the "Actions" menu on the top right of the Document Controller. This appears every time you select a document from the list:

Ideally I would like to remove the button all together, though if I could disable it or disable all the options inside it that would also suffice. I found this question:

Open in + UIDocumentInteractionController : how to filter options in SDK iOS 6 (canPerformActions is deprecated)

But I couldn't figure out how to use the suggestion to disable the options inside the menu. I have uploaded the modified sample code here:

http://plasma.servebeer.com/DocSampleCode.zip

One final note is this will not be going on the App Store it is for private, personal use, so if there is an unofficial way then I would be interested in knowing that too.

Any help would be greatly appreciated, thanks in advance.

Plasma

解决方案

Use UINavigationControllerDelegate

@interface DITableViewController () <UIDocumentInteractionControllerDelegate, UINavigationControllerDelegate>

Assign navigationController delegate to self

- (void)viewDidLoad {

    [super viewDidLoad];
    self.navigationController.delegate = self;
}

Change documentInteractionControllerViewControllerForPreview

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)interactionController {

    return self.navigationController;
}

Add this UINavigationControllerDelegate method

// Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack.
- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {

    if ([viewController isKindOfClass:[QLPreviewController class]]) {
        viewController.navigationItem.rightBarButtonItem = nil;
    }
}

Update for MP4 files

In MP4 files the action button is on the UIToolbar

- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if ([viewController isKindOfClass:[QLPreviewController class]]) {
        viewController.navigationItem.rightBarButtonItem.customView = [[UIView alloc] init];
        UIBarButtonItem *item = viewController.toolbarItems.firstObject;
        item.customView = [[UIView alloc] init];
    }
}

N.B. This might not work in future versions of iOS

这篇关于UIDocumentInteractionController删除操作菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆