Can you set the text based on the application user chooses to share with UIActivityViewController?

戏子无情 提交于 2019-12-13 07:22:10

问题


So for example, if the user wants to share with twitter, the text would be different than if a user chooses to share with email.

How would I code that with initWithActivityItems?:

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

回答1:


Instead of objectsToShare, supply an object that adopts the UIActivityItemSource protocol. This protocol means your object will be called with activityViewController:itemForActivityType:. The second parameter that tells you the activity type. Thus you can return a different item, depending on the activity type.



来源:https://stackoverflow.com/questions/40296314/can-you-set-the-text-based-on-the-application-user-chooses-to-share-with-uiactiv

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