问题
I want to exclude Add to iCloud Drive, Add to Reading List, Save to Files & Print
from share sheet.
I could exclude Add to Reading List and Print options using following code. Because these type properties have been provided.
activityViewController.excludedActivityTypes = [ UIActivityType.print, UIActivityType.addToReadingList ]
After with when I search google I found a way to remove options which are not included in type properties as follows (Ex: Add to iCloud drive)
UIActivityType(rawValue: "com.apple.CloudDocsUI.AddToiCloudDrive")
I want to know that how can we find row values to exclude other options which are not defined in type properties. For instance Save to Files
回答1:
I tried Geoff's suggestion (logging the UIActivityType
by implementing a completionWithItemsHandler
) for my purposes: disabling 'Add to Notes', 'Add Reminder', and 'Save to Files'. It works EXCEPT for 'Save to Files'.
The logged type of the Save to Files UIActivityType
is the same one listed in this question, and adding this to the excludedActivityTypes
does not work as of iOS 11.1.2. Others (here, and here) have run into this issue as well.
For the time being it seems there is no way to exclude the Save To Files UIActivityType
. Hopefully Apple will update the documentation on how to do so soon.
回答2:
The simplest way to determine what UIActivityType
values are used for undocumented types is to add a completionWithItemsHandler:
block which logs the UIActivityType
parameter that it is called with. Then use your app to share something and select the activity type that you want to find the value for. The completion hander will be called, logging its type.
Alternatively, you can create your own object which implements UIActivityItemSource
, add that to the item activities that you are sharing and implement activityViewController(_:itemForActivityType:)
and log the type.
来源:https://stackoverflow.com/questions/46965962/share-sheet-exclude-options-which-are-not-provided-as-type-properties-in-uiact