简体   繁体   English

Sharekit2.0:如何直接共享到Facebook和Twitter,而不是通过UIActionSheet?

[英]Sharekit2.0: how can I directly share to facebook and twitter, rather than via UIActionSheet?

I'm using the latest Sharekit2.0 on a project. 我在一个项目上使用最新的Sharekit2.0。

Two buttons are listed ("Get votes on Facebook" and "Share on twitter") as attached, so I don't need a UIActionSheet to prompt. 附件中列出了两个按钮(“在Facebook上获取投票”和“在Twitter上共享”),因此不需要UIActionSheet来提示。 How can I directly share text information to facebook and twitter respectively. 如何直接将文本信息分别共享到Facebook和Twitter。

Thanks 谢谢

could you please try the following: 您能否尝试以下方法:

#import "SHK.h"
#import "SHKFacebook.h"
#import "SHKTwitter.h"

then for facebook 然后是脸书

-(IBAction)forFacebook:(id)sender;{
    NSString *someText = @"This is a blurb of text I highlighted from a document.";
    SHKItem *item = [SHKItem text:someText];  

    [SHKFacebook shareItem:item];    

}

for twitter 推特

-(IBAction)forTwitter:(id)sender;{
    NSString *someText = @"This is a blurb of text I highlighted from a document.";
    SHKItem *item = [SHKItem text:someText];  

    [SHKTwitter shareItem:item];    

}

please give me a feedback, thanks. 请给我反馈,谢谢。

Another Way: 其他方式:

#import "SHK.h"

-(IBAction)forSharing:(id)sender{

    NSString *someText = @"This is a blurb of text I highlighted from a document.";
    SHKItem *item = [SHKItem text:someText]; 

    SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; 

    [actionSheet showFromToolbar:navigationController.toolbar];   

}

But you need to change the function favoriteSharersForType in shk.m to show only twitter and facebook options. 但是您需要在shk.m中更改函数favoriteSharersForType以仅显示twitter和facebook选项。

if (favoriteSharers == nil)
    {
        switch (type) 
        {
            case SHKShareTypeURL:
                favoriteSharers = SHKCONFIG(defaultFavoriteURLSharers);
                break;

            case SHKShareTypeImage:
                favoriteSharers = SHKCONFIG(defaultFavoriteImageSharers);
                break;

            case SHKShareTypeText:
                favoriteSharers = SHKCONFIG(defaultFavoriteTextSharers);
                break;

            case SHKShareTypeFile:
                favoriteSharers = SHKCONFIG(defaultFavoriteFileSharers);
                break;

            default:
                favoriteSharers = [NSArray array];
        }

        // Save defaults to prefs
        [self setFavorites:favoriteSharers forType:type];
    }

and change the variable defaultFavoriteURLSharers in DefaultSHKConfigurator.m to show only facebook and twitter like this: 并在DefaultSHKConfigurator.m中将变量defaultFavoriteURLSharers更改为仅显示facebook和twitter,如下所示:

- (NSArray*)defaultFavoriteURLSharers {
    return [NSArray arrayWithObjects:@"SHKFacebook",@"SHKTwitter", nil];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM