By default, Sharekit uses an actionSheet to sharing items.
Is there any way to show only specific items, such as only facebook, twitter, and email, in a small UIView
, not in an actionSheet?
Edit: Put another way:
I have 3 buttons in my UIView
, one for facebook, twit开发者_运维技巧ter and email. I don't want to use Sharekit's actionSheet. Is there any way to call FBConnect, Twitter and Email sharing, one by one, in Sharekit by pressing my UIButton
's?
i found it here:
http://getsharekit.com/docs/#specific-service
Yes. It will take a little 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;
to the following for each instance of the switch statement
favoriteSharers = [NSArray arrayWithObjects:@"SHKFacebook", nil];
or what ever other options you want to support (ie if you only want twitter and facebook add @"SHKTwitter"
, to the array)
that will eliminate the other options but the action sheet that displays the options wont reflect the change and it will still give the more option, which we also need to disable.
So to do that go to SHKActionSheet.m
While in this method you can optionally change the title from "Share" to something more specific, ie. "Share with Facebook and Twitter". To do that, go to the following method and make the change indicated.
+ (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 that same method, remove this line:
// Add More button
[as addButtonWithTitle:SHKLocalizedString(@"More...")];
The reason why we have to remove this is because earlier we removed the more button, and now we have to make sure the code doesn’t confuse any other button with the more button. The more button had to be removed because it revealed options to use other sharing methods we don’t want the user to use. If we didn't remove it, the user would still be able to access a disabled share method.
Hope this helps.
The new way to do this with latest version of ShareKit 2.0 is to overwrite the following methods in your SHKConfigurator (extending 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's 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];
}
精彩评论