Share data with different types in UIActivityViewController

后端 未结 2 1886
慢半拍i
慢半拍i 2021-01-03 05:05

There is a extremely similar question asked by the following post: Different data for sharing providers in UIActivityViewController. But my question is different.

I

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 05:41

    You'd want to create and share two or more objects that conform to the UIActivityItemSource, where one returns the String, another one an Image, etc. Then when the delegate callback requesting the item is called you check which activity type was selected (Facebook, Mail, AirDrop, etc) and have one or multiple of the ItemSource's return nil if that item doesn't apply to that activity. Make sure for any chosen activity that at least one of the item's return a non-nil value.

    You can take a look at the airdrop sample code to get some examples of how to implement UIActivityItemSource

提交回复
热议问题