
效果如图:
分享过来的文件,会存在沙盒下的Documents/Inbox文件夹下。
可以在AppDelegate中重写openURL方法
这里需要注意NSURL转NSString,需要用UTF-8处理下。
这样就可以获取其他App的文件了
调用下面的方法即可实现系统分享功能
//分享
- (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
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)