从iphone分享Twitter上的href链接

时间:2014-12-05 06:34:28

标签: iphone

enter image description here我正在iphone应用程序上实现Twitter上的href链接共享..我正在使用社交共享框架.. 我使用下面的代码为href url ..但是无法在twitter上发布href url  NSString * ss = @“http://www.w3schools.com/html>访问我们的HTML教程”;  [twComposer addURL:[NSURL URLWithString:ss]];

            [twComposer setCompletionHandler:completionHandler];
            [self presentViewController:twComposer animated:YES completion:nil];

你能帮帮我吗

1 个答案:

答案 0 :(得分:0)

您可以使用以下功能发布指向twitter的链接:

- (IBAction)postToTwitter:(id)sender {
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

        [controller setTitle:@"Tweet from My Application"];

        NSString *strLink = [NSString stringWithFormat:@" Please refer link http://www.w3schools.com/html Visit our HTML tutorial "];

        [controller setInitialText:strLink];

        [self presentViewController:controller
                           animated:YES completion:nil];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {
                NSLog(@"cancel twitter");
            } else {
                NSLog(@"post twitter");
            }
        };
        controller.completionHandler = myBlock;
    }
}

查看我编辑的代码!!

希望这会有所帮助...... 一切顺利!!!