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

我正在使用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];

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...