iOS社交-LINE的分享代码

 

其中urlStr为我要分享的内容。分享的为Text与图片

//LINE


- (void)shareWithLine:(NSString *)urlStr
{
 //分享文字
 NSString *contentType = @"text";
 NSString *urlString = [NSString stringWithFormat:@"line://msg/%@/%@",
 contentType, 
 [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
 /******分享图片
 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
 [pasteboard setData:UIImageJPEGRepresentation(
 [UIImage imageNamed:@"account_icon_friend.png"] , 1.0) 
 forPasteboardType:@"public.jpeg"];
 
 NSString *contentType = @"image";
 NSString *urlString = [NSString
 stringWithFormat:@"line://msg/%@/%@",
 contentType, pasteboard.name]; //从剪切板中获取图片,文字亦可以如此
 */
 NSURL *url = [NSURL URLWithString:urlString];
 LorwyLog(@"%@",url);
 if ([[UIApplication sharedApplication] canOpenURL:url]) {
 [[UIApplication sharedApplication] openURL:url];
 }
 else{
 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" 
 message:@"无效的url" delegate:self 
 cancelButtonTitle:@"OK" 
 otherButtonTitles:nil, nil];
 [alert show];
 }
}

 

标签:
,
分类:iOS开发 | 发布:inzaghi | 评论:0 条 | 发表时间:2016-03-1 15:07
引用:点击这里获取该日志的TrackBack引用地址
上一篇:
下一篇:

发表评论

你必须 登录后 才能对文章进行评论!

Design By Inzaghi | 京ICP备16047555号-1