有没有办法定制Sharekit?

发布于 2024-10-21 09:26:49 字数 315 浏览 5 评论 0原文

默认情况下,Sharekit 使用 actionSheet 来共享项目。 有没有办法在一个小的 UIView 中而不是在 actionSheet 中仅显示特定的项目,例如仅 facebook、twitter 和电子邮件?

编辑: 换句话说:

我的 UIView 中有 3 个按钮,一个用于 facebook、twitter 和电子邮件。我不想使用 Sharekit 的 actionSheet。有没有办法通过按我的 UIButton 来在 Sharekit 中一一调用 FBConnect、Twitter 和电子邮件共享?

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, twitter 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

§对你不离不弃 2024-10-28 09:26:49

是的。这将需要一些工作,但可以按如下方式完成:

SHK.m 中找到此方法

+ (NSArray *)favoriteSharersForType:(SHKShareType)type

更改

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;

,并将switch 语句的每个实例

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

或您想要支持的其他选项 为以下内容(即,如果您只想 twitter 和 facebook 添加 @"SHKTwitter", 到数组中)

,这将消除其他选项,但显示选项的操作表不会反映更改,它仍然会提供更多选项,我们还需要禁用它。

因此,要执行此操作,请转到 SHKActionSheet.m

在这种方法中,您可以选择将标题从“共享”更改为更具体的内容,即。 “与 Facebook 和 Twitter 分享”。为此,请转至以下方法并进行指示的更改。

+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type

更改

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;

然后在相同的方法中

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

,删除这一行:我们必须删除这一行的原因是因为之前我们删除了“更多”按钮,现在我们必须确保代码不会将任何其他按钮与“更多”按钮混淆。必须删除“更多”按钮,因为它显示了使用我们不希望用户使用的其他共享方法的选项。如果我们不删除它,用户仍然可以访问禁用的共享方法。

希望这有帮助。

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.

沩ん囻菔务 2024-10-28 09:26:49

使用最新版本的 ShareKit 2.0 执行此操作的新方法是覆盖 SHKConfigurator 中的以下方法(扩展 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];
}

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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文