iOS調(diào)用系統(tǒng)分享功能

調(diào)用下面的方法即可實(shí)現(xiàn)系統(tǒng)分享功能

//分享

- (IBAction)RespostClick_Action:(id)sender {

UIImage* image = [UIImage imageNamed:@"icon_share.png"];

NSString *text = @"I found an Awesome application software! InstaDown";

//https://itunes.apple.com/us/app/id1260302654?l=zh&ls=1&mt=8

NSURL *urlToShare = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/id%@?l=zh&ls=1&mt=8",[HHLADSManager getValueFromjsondata:@"appid"]]];

NSArray *activityItems = @[text,image,urlToShare];

UIActivityViewController *avc = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];

[self presentViewController:avc animated:TRUE completion:nil];

// 選中分享類型

[avc setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){

// 顯示選中的分享類型

NSLog(@"act type %@",activityType);

if (completed) {

NSLog(@"ok");

}else {

NSLog(@"no ok");

}

}];

UIPopoverPresentationController *popover = avc.popoverPresentationController;

if (popover) {

popover.sourceView = self.view;

popover.sourceRect = self.view.bounds;

popover.permittedArrowDirections = UIPopoverArrowDirectionUp;

}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容