Post multiple urls in one post using iphone sharekit

穿精又带淫゛_ 提交于 2020-01-15 06:27:48

问题


I want to post text(on twitter, fb, mail) like following using share kit:

Hi,

This is share text

Click here to do something <=== this should be a link

Click here to another something <=== this should be a link

Cheers

I have following code:

-(IBAction)shareOnTwitter:(id)sender
{
    [SHK setRootViewController:self];
    SHKItem *item;
    NSURL *url = [NSURL URLWithString:@"http://dosomething.com"];
    item = [SHKItem URL:url title:@"HI,\n\nThis is share text\n\nCheers"];
    [SHKTwitter shareItem:item];

}

- (IBAction)shareOnFacebook:(id)sender
{
    SHKItem *item;
    NSURL *url = [NSURL URLWithString:@"http://dosomething.com"];
    item = [SHKItem URL:url title:@"HI,\n\nThis is share text\n\nCheers"];
    [SHKFacebook shareItem:item];

}

- (IBAction)shareWithMail:(id)sender
{
    SHKItem *item;
    NSURL *url = [NSURL URLWithString:@"http://dosomething.com"];
    item = [SHKItem URL:url title:@"HI,\n\nThis is share text\n\nCheers"];
    [SHKMail shareItem:item];

}

But the url is appended at the end. How can I add multiple links with my text and bring the links in the middle.


回答1:


You will have to change the ShareKit classes that handle these services:

  • SHKFacebook.m: the "-(BOOL)send" method.
  • SHKTwitter.m: the "-(void)showTwitterForm" method.
  • SHKMail.m: the "-(BOOL)sendMail" method.

It's easy for Twitter and Mail, you only have to create a NSString with the text of the message, like you want. With Facebook you have to change the attachment, you can see the facebook API here for more options.




回答2:


I just looked in the documentation. ShareKit isn't designed to share long information. Only text, images, files or urls (and only one at a time). You will have to dig into programming them on your own (or find a better library).

  • for mail you can read the documentation of MFMailComposeViewController
  • for twitter and facebook you need something different, just watch for an web tutorial



回答3:


Basically you want to first create html formatted text with links inside, and then load it to text SHKItem and share that.

SHKItem *item = [SHKItem text:yourHTMLFormattedString];
[SHKMail shareItem:item];

It might need some customization, as each service might handle html formatted text differently. but at least mail sharer should have no problems.

URL SHKItem is for different purpose - solely for single URL sharing, and each sharer handles it differently, eg. Facebook automatically adds image from webpage, Twitter shortens it etc.

One more hint, just for case you are not aware - there is ShareKit 2.0 which has some new features, is updated and maintained.



来源:https://stackoverflow.com/questions/10124340/post-multiple-urls-in-one-post-using-iphone-sharekit

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