Share sheet - exclude options which are not provided as Type Properties in UIActivityType

匆匆过客 提交于 2019-12-12 12:21:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!