【问题标题】:Share current URL of UIWebview to Facebook and Twitter将 UIWebview 的当前 URL 分享到 Facebook 和 Twitter
【发布时间】:2013-07-11 17:35:36
【问题描述】:

所以我想使用 Xcode 中的社交框架将我的 webview 的当前 URL 分享到 facebook 和 twitter,谁能告诉我如何做到这一点,这是我的代码

- (IBAction)social:(id)sender {
    UIActionSheet *share = [[UIActionSheet alloc] initWithTitle:@"Pass on the news!" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:@"Post to Twitter", @"Post to Facebook", nil];

    [share showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (actionSheet.tag == 0) {
        if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
            SLComposeViewController *tweetSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
            [tweetSheet setInitialText:@"Check out this article I found using the 'Pass'  iPhone app: "];
            [self presentViewController:tweetSheet animated:YES completion:nil];
        } else {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have at least one Twitter account setup and your device is using iOS6 or above!." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
        }
    }
}

【问题讨论】:

    标签: ios url uiwebview share


    【解决方案1】:

    [tweetSheet addURL:self.webView.request.URL];

    【讨论】:

    • 非常感谢!现在看起来很简单(:对于查看此内容的其他任何人,这就是 Facebook 的做法:[facebookSheet addURL:self.newsItemWebView.request.URL];
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 2020-05-06
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    • 2015-03-31
    相关资源
    最近更新 更多