如何从我的应用程序分享照片到Twitter应用程序?

时间:2015-04-29 03:24:07

标签: ios image twitter

我构建了一个应用程序,当我从我的应用程序(通过IOS共享按钮)向Twitter应用程序分享照片时,它只能显示链接,我想成为一个显示图片。我怎样才能实现它?

2 个答案:

答案 0 :(得分:2)

首先尝试导入社交框架

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
    SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    if (composeViewController) {
        [composeViewController addImage:[UIImage imageNamed:@"Your Image"]];
        [composeViewController addURL:[NSURL URLWithString:@"Your URL"]];
        NSString *initialTextString = @"Tour Tweet";
        [composeViewController setInitialText:initialTextString];
        [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) {
            if (result == SLComposeViewControllerResultDone) {
                NSLog(@"Posted");
            } else if (result == SLComposeViewControllerResultCancelled) {
                NSLog(@"Post Cancelled");
            } else {
                NSLog(@"Post Failed");
            }
        }];
        [self presentViewController:composeViewController animated:YES completion:nil];
    }
}

有关SLComposeViewController

的更多信息,请浏览https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/SLComposeViewController_Class/

答案 1 :(得分:1)

尝试此操作,您可以通过应用轻松在Twitter上分享照片。你也可以访问twitter的其他选项。

https://github.com/ronaldwang/FHSTwitterEngine