//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];
}
}
原创文章如转载请注明:你必须 登录后 才能对文章进行评论!