调用下面的方法即可实现系统分享功能
//分享
- (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;
}
}