我想用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];
答案 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];