4

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?

Maximilian Litteral
  • 3,059
  • 2
  • 31
  • 41

3 Answers3

5

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

elp
  • 8,021
  • 7
  • 61
  • 120
Maximilian Litteral
  • 3,059
  • 2
  • 31
  • 41
5

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
}
Tricertops
  • 8,492
  • 1
  • 39
  • 41
0

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.

Dmitry Shevchenko
  • 31,814
  • 10
  • 56
  • 62
  • well i have them, but it will set the text and url. so its adding the url twice basically because the activity items is a url and string. but in Safari they only have the url and the copy function is copying a string because i can paste it into messages – Maximilian Litteral Feb 09 '13 at 17:01
  • @MaxHasADHD can you post some code with contents of your activityItems and what exactly do you expect. It looks like if you put just the url as NSString, you will be able to copy it _and_ twitter will insert it as text, not url. – Dmitry Shevchenko Feb 10 '13 at 03:19
  • Ya, i want it to be a NSString activity item, but if want twitter and facebook to include it as a url not a initial text. if i include both then twitter and facebook set it as text and a url. if i use just the url and copy it, then i cant paste it into messages app, safari can. Is there a way to tell twitter to only use the url not the string w/o making a custom activity class? and if i had to make a class can i use a full icon so it looks the same? – Maximilian Litteral Feb 10 '13 at 06:19