簡體   English   中英

無法使用iOS 7.1中的UIActivityViewController在Facebook和Twitter上共享URL

[英]Not able to share URL on Facebook and Twitter using UIActivityViewController in iOS 7.1

我正在使用UIActivityViewController進行分享按鈕。當我從列表中選擇郵件選項時它顯示文本和網址但是當我選擇Facebook或Twitter時它只顯示文本而不是網址。我搜索了很多但沒有得到我的問題的解決方案。我得到了在url中添加“http”的另一個解決方案,但這可能不在url中添加http。 我的代碼是 -

 NSArray *activityItems;
NSString *str;
NSString *noteStr;
str = [NSString stringWithFormat:@"com.boxscoregames.squares://square?%@",squareID];
noteStr = @"You have been invited to join the Square game, please follow the link below on your iPhone.";
NSURL *url = [NSURL URLWithString:str];

// str =[NSString  stringWithFormat:@"<html><a href=\"%@\">%@</a></html>" ,str,str];
activityItems = @[noteStr,url];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

我相信這個鏈接確實沒有顯示出來。 但是,當您發布它時,該鏈接將添加到您的Facebook / Twitter帖子中。

當然,您也可以添加文本鏈接。

NSString *link = [NSString stringWithFormat:@"com.boxscoregames.squares://square?%@",squareID];
NSString *noteStr = [NSString stringWithFormat:@"You have been invited to join the Square game, please follow the link below on your iPhone. %@", link];

NSURL *url = [NSURL URLWithString:link];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[noteStr, url] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM