活动视图控制器在新行中显示URL

时间:2015-09-01 06:28:31

标签: ios objective-c mfmailcomposeviewcontroller uiactivityviewcontroller

我想用UIActivityViewController在单行中显示text + Url。但它在新行中显示URL。我使用以下代码

NSString *text = [NSString stringWithFormat:@"%@%@",@"Hello:",@" - "];
 NSURL *url = [NSURL URLWithString:@"http://www.raywenderlich.com/84174/ios-8-handoff-tutorial"];

UIActivityViewController *controller =[[UIActivityViewController alloc]initWithActivityItems:@[[NSString stringWithFormat:@"%@%@",text,url]] applicationActivities:nil];
[controller setValue:@"Hello" forKey:@"subject"];

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

这是附带的截图。 enter image description here 任何帮助赞赏!!感谢

1 个答案:

答案 0 :(得分:0)

你可以通过在

中添加html代码来做一个技巧
UIActivityViewController *controller =[[UIActivityViewController alloc]initWithActivityItems:@[@"Hello:-  <html><body><a href=\"http://www.raywenderlich.com/84174/ios-8-handoff-tutorial\">link text</a></body></html>"] applicationActivities:nil];

注意:它不可能按原样查看冗长的URL,但你可以通过另一种棘手的方式来做到这一点,在链接中的文本之间添加空格,如下所示,

UIActivityViewController *controller =[[UIActivityViewController alloc]initWithActivityItems:@[@"Hello:-  <html><body><a href=\"http://www.raywenderlich.com/84174/ios-8-handoff-tutorial\">http://www.raywenderlich.com /84174/ ios-8-handoff-tutorial </a></body></html>"] applicationActivities:nil];