Is there a way to set up Sharekit?

By default, Sharekit uses the actionSheet file to share items. Is there a way to show only certain elements, such as facebook, twitter and email only, in a small UIView and not in an ActionSheet?

Edit: In other words:

I have 3 buttons in my UIView , one for facebook, twitter and email. I do not want to use ShareKit actionSheet. Is there a way to call FBConnect, Twitter and email one by one in Sharekit by pressing the UIButton button?

+4
source share
3 answers

Yes. It takes a bit of work, but it can be done as follows:

in SHK.m find this method

 + (NSArray *)favoriteSharersForType:(SHKShareType)type 

and change

 switch (type) { case SHKShareTypeURL: favoriteSharers = [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook",@"SHKReadItLater",nil]; break; case SHKShareTypeImage: favoriteSharers = [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook",@"SHKReadItLater",nil]; break; case SHKShareTypeText: favoriteSharers = [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook",@"SHKReadItLater",nil]; break; case SHKShareTypeFile: favoriteSharers = [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook",@"SHKReadItLater",nil]; break; 

for each instance of the switch statement

 favoriteSharers = [NSArray arrayWithObjects:@"SHKFacebook", nil]; 

or any other parameters you want to support (i.e. if you want twitter and facebook to add @"SHKTwitter" to the array)

which will eliminate the other parameters, but the action sheet that displays the parameters does not reflect the change, and it will still provide more options that also need to be disabled.

To do this, go to SHKActionSheet.m

In this method, you can change the title from "Share" to something more specific, i.e. "Share with Facebook and Twitter." To do this, go to the next method and make the indicated change.

 + (SHKActionSheet *)actionSheetForType:(SHKShareType)type 

change

 SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"PUT YOUR NEW TITLE HERE") delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; as.item = [[SHKItem alloc] init]; as.item.shareType = type; 

then in the same method delete this line:

  // Add More button [as addButtonWithTitle:SHKLocalizedString(@"More...")]; 

The reason we need to remove this is because we previously deleted more buttons, and now we need to make sure that the code does not confuse any other button with the button anymore. The more buttons you had to remove, because it was discovered options for using other exchange methods that we do not want to use. If we do not delete it, the user will still be able to access the disabled share method.

Hope this helps.

+3
source

A new way to do this with the latest version of ShareKit 2.0 is to overwrite the following methods in your SHKConfigurator (extension DefaultSHKConfigurator.m)

 // SHKActionSheet settings - (NSNumber*)showActionSheetMoreButton { return [NSNumber numberWithBool:true];// Setting this to true will show More... button in SHKActionSheet, setting to false will leave the button out. } /* Favorite Sharers ---------------- These values are used to define the default favorite sharers appearing on ShareKit action sheet. */ - (NSArray*)defaultFavoriteURLSharers { return [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook", @"SHKReadItLater", nil]; } - (NSArray*)defaultFavoriteImageSharers { return [NSArray arrayWithObjects:@"SHKMail",@"SHKFacebook", @"SHKCopy", nil]; } - (NSArray*)defaultFavoriteTextSharers { return [NSArray arrayWithObjects:@"SHKMail",@"SHKTwitter",@"SHKFacebook", nil]; } 
+1
source

Source: https://habr.com/ru/post/1343529/


All Articles