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

前端 未结 2 332
轻奢々
轻奢々 2020-12-10 12:30

Since the new SDK was release (iOS 6), the delegate method documentInteractionController:canPerformAction: of the UIDocumentInteractionControllerDelegate<

相关标签:
2条回答
  • 2020-12-10 12:51

    Agreed on the fact that deprecating 'canPerformAction' in the delegate is troublesome, we lost the fine grain control we used to have.

    However, if all you want is to allow a document to be opened in another app, and wanted to remove Copy, Print and even Mail, I guess you are better off using OpenIn version of method to present the UIDocumentInteractionController?

    i.e. for your UIDocumentInteractionController use presentOpenInMenuFromBarButtonItem:animated: or presentOpenInMenuFromRect:inView:animated:

    (instead of presentOptionsMenuFromBarButtonItem:animated: or presentOptionsMenuFromRect:inView:animated:)

    This way, by default, it will only show apps that can open your document, and hides Mail, Copy and Print.

    0 讨论(0)
  • 2020-12-10 12:59

    I think it is because Apple wants you to use the new UIActivity control.

    Here it's the documentation:

    http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIActivity_Class/Reference/Reference.html

    Here it's a custom control developed to support many third party apps:

    http://www.cocoacontrols.com/platforms/ios/controls/uiactivitycollection

    And this question solves how could you make your own UIActivity:

    https://stackoverflow.com/a/12766330/736384

    So, if you don't want the user can use copy: and print: methods just pass this activities to the UIActivityViewController, like this:

    [activityView setExcludedActivityTypes:[NSArray arrayWithObjects:UIActivityTypeCopyToPasteboard, UIActivityTypePrint, nil]];
    

    All the default activities are listed at the bottom of the Apple's documentation link.

    0 讨论(0)
提交回复
热议问题