问题
I have a UIActivityViewController and i want to make it have all the actions safari does and more. Currently i can only get mail, messages, twitter, facebook and a semi-working copy. I set the activity items array with a url. I then added a nsstring of that url and added that with the url, and everything worked good like copying worked better by copying the string and i paste it in more areas. But when having the string also, twitter and facebook added the urls into their text and include the link. How can i make it so they dont have the text, just the link? Another issue is how can i show the web view preview in the link on the twitter and facebook activities? it just shows a safari icon. And third question is how can i print the contents of the web page?
回答1:
To provide different items for different services, you subclass UIActivityItemProvider
. It conforms to UIActivityItemSource
protocol, so you implement method:
- (id)activityViewController:(UIActivityViewController *)activityViewController
itemForActivityType:(NSString *)activityType {
// compare `activityType` and return what you want
}
回答2:
I found this https://www.albertopasca.it/whiletrue/objective-c-custom-uiactivityviewcontroller-icons-and-text/ which shows how to do different content for each service
回答3:
For twitter or facebook, you would want to setup UIActivity with correct type of twitter/facebook post (see Constants at the bottom here) and payload.
来源:https://stackoverflow.com/questions/14783552/uiactivityviewcontroller-use-items-in-specific-actions