2

我不会在 tumbler/twitter/Facebook/其他社交网站上分享我的文本(字符串)。

我不知道如何分享。任何人都可以有想法或示例代码吗?

请帮我。

提前致谢。

4

2 回答 2

3

如果您想分享表情符号键盘,请在此处查看 http://www.easyapns.com/blog以及用于分享的社交框架。

-(void)openFBController
{


SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook] == NO) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"This device is not able to Share Facebook or Facebook account is not configured." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];

}

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
    SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){

        [fbController dismissViewControllerAnimated:YES completion:nil];

        switch(result){
            case SLComposeViewControllerResultCancelled:
            default:
            {
                NSLog(@"Cancelled.....");

            }
                break;
            case SLComposeViewControllerResultDone:
            {
                NSLog(@"Posted....");

                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"PeekAboo!" message:@"Post Successfully." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                [alert show];
            }
                break;
        }};

    [fbController addImage:[UIImage imageNamed:@"@"give ur imagename""]];
    [fbController setInitialText:@"give ur text"];

    [fbController addURL:[NSURL URLWithString:@"give ur url"]];
    [fbController setCompletionHandler:completionHandler];
    [self presentViewController:fbController animated:YES completion:nil];
}


//Note:It doesn't show the old albums list to select in fbController in my account,
//I don't know if thats the case with other people as well.
//After I created and transfered the data from FB to device FB.
//All the albums created afterwards were shown in the list.

}


- (void)canTweetStatus {


SLComposeViewController *TweetStatusController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter] == NO) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"This device is not able to Share Twitter or Twitter account is not configured." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];

}


if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
    SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){

        [TweetStatusController dismissViewControllerAnimated:YES completion:nil];

        switch(result){
            case SLComposeViewControllerResultCancelled:
            default:
            {
                NSLog(@"Cancelled.....");

            }
                break;
            case SLComposeViewControllerResultDone:
            {
                NSLog(@"Posted....");
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"PeekAboo!" message:@"Post Successfully." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                [alert show];
            }
                break;
        }};

    [TweetStatusController addImage:[UIImage imageNamed:@"icon.png"]];
    [TweetStatusController setInitialText:@"give ur text"];
    [TweetStatusController addURL:@"give ur url"]];
    [TweetStatusController setCompletionHandler:completionHandler];
    [self presentViewController:TweetStatusController animated:YES completion:nil];
}


}
于 2013-10-01T07:32:41.273 回答
0

Facebook 有一个 API,而 Twitter 有一个引擎。查看https://github.com/mattgemmell/MGTwitterEngine以获取 Twitter。和https://github.com/facebook/facebook-ios-sdk用于 facebook。

Stackoverflow 上也有很多关于这个的问题。我建议你在问之前先看看周围。

于 2012-07-02T18:31:48.113 回答