开发者

ShareKit changes?

开发者 https://www.devze.com 2023-03-13 05:25 出处:网络
I haven\'t used ShareKit much, but I want to have only three sharing options: Facebook, Twitter, and Email. ShareKit gives far more options, including a More button. However, I don\'t want the More op

I haven't used ShareKit much, but I want to have only three sharing options: Facebook, Twitter, and Email. ShareKit gives far more options, including a More button. However, I don't want the More option, just the three.

In SHKActionSheet.m of ShareKit:

// Add More button
[as addButtonWithT开发者_StackOverflow中文版itle:SHKLocalizedString(@"More...")];

ShareKit changes?


It is super easy now, if you use ShareKit 2.0.

  1. edit SHKSharers.plist to include only sharers you need. In case you do not want to compile unused sharers files, check granular install.

  2. You can hide "more..." button in configurator. The new setting is - (NSNumber*)showActionSheetMoreButton

  3. You can disable favourites reordering in configurator. Normally last used sharer is on the top in ShareKit's action sheet. The new setting is - (NSNumber*)autoOrderFavoriteSharers

Using this way you do not need to change or add any code to ShareKit.


I wanted to have the same thing. I spent days to make ShareKit work without too much success. Ok I was able to post FB, Twitter and Email messages but it was more pain the convenience.

Sharekit is an awesome idea but:

  • You cannot share image, URL and text at the SAME TIME! It has to be text only, URL only or Image only. Probably you want your user to post something on FB or Twitter or send an email about your App. What's the point if the message cannot contain an App Store or webpage link?
  • Very badly documented often you have to post questions on StackoverFlow
  • It's buggy, not supported by the original designer so there are dozens of forks. You can pick the ShareKit fork, but still.
  • On it's website it sounds like it's a drag and drop and you can make it work in minutes, good luck for that.

It takes 5 lines to add twitter, about 50 for Facebook and email to support text, URL and photo at the same time.

Twitter: This code sends a message with User editable text, URL (hidden, not editable) and an image. It took me 5 minutes to figure it out.

#import  <Twitter/TWTweetComposeViewController.h>

- (IBAction)twitterButton:(id) sender {
   TWTweetComposeViewController *tweetView = [[TWTweetComposeViewController alloc] init];
   [tweetView setInitialText:@"Check out this app, it's awesome" ];
   [tweetView addImage:[UIImage imageNamed:@"MyImage.png"]];
   [tweetView addURL:[NSURL URLWithString:appDelegate.appStoreURL]]; 
   [self presentModalViewController:tweetView animated:YES];
}

I really appreciate the effort of creating Sharkit but personally I cannot recommended it unless you really need to support all of those sharers and you happy with limited functionality.

UPDATE: I implemented Facebook sharing myself. It was more difficult than I thought. The main problem is that you cannot upload a photo with a post because Facebook only accept image links. Even worse Facebook does not allow to link to a photo which is uploaded to the user photo album (very easy) as it must be an external link. For static images you can use a URL shortener to get around it but for user generated images pretty much you have to use Amazon S3 or something else. Amazon S3 is super easy to use, I figured out how to use upload files in an hour or so.


If you don't want the More... button, why don't you take out the line of code that adds it?


you need to make this code changes from SHKActionSheet.m

+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
// Add More button
//[as addButtonWithTitle:SHKLocalizedString(@"More...")];


- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated

// More
//  else if (buttonIndex == sharers.count)
//  {
//      SHKShareMenu *shareMenu = [[SHKCustomShareMenu alloc]   
//          initWithStyle:UITableViewStyleGrouped];
//      shareMenu.item = item;
//      [[SHK currentHelper] showViewController:shareMenu];
//      [shareMenu release];
//  }

And you can edit SHKSharers.plist for services you like.


you can use the below definition for dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated

you need to delete the few lines which is commented in the below definition.

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
{
    // Sharers
    if (buttonIndex >= 0 && buttonIndex < sharers.count)
    {
        [NSClassFromString([sharers objectAtIndex:buttonIndex]) performSelector:@selector(shareItem:) withObject:item];
    }

    // More
    //else if (buttonIndex == sharers.count)
//  {
//      SHKShareMenu *shareMenu = [[SHKCustomShareMenu alloc] initWithStyle:UITableViewStyleGrouped];
//      shareMenu.item = item;
//      [[SHK currentHelper] showViewController:shareMenu];
//      [shareMenu release];
//  }

    [super dismissWithClickedButtonIndex:buttonIndex animated:animated];
}


Excellent solution, however in my case for example want to use Facebook as well and there is no way to share content natively in iOS5. Another problem is that those who need the app compatible with iOS4.0 or higher (my case) can not, because this method only works from 5.0.

How to solve this? ShareKit to Use Facebook and Twitter for the native methods and forget about compatibility with iOS4.0?

0

精彩评论

暂无评论...
验证码 换一张
取 消