美文网首页
pad开发中调用系统原生社会化分享

pad开发中调用系统原生社会化分享

作者: Calvin_83d4 | 来源:发表于2017-09-01 15:56 被阅读0次

我们需要调用系统UIActivityViewController类

// 要分享的图片

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

// 要分享的文字

NSString *str=@"Image form My app";

// 将要分享的元素放到一个数组中

NSArray *postItems=@[str,image];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:postItems applicationActivities:nil];

UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityVC];

// 在展现 activityVC 时,必须根据当前的设备类型,使用适当的方法。在iPad上,必须通过popover来展现view controller。在iPhone和iPodtouch上,必须以模态的方式展现。

if ([[UIDevice currentDevice].model isEqualToString:@"iPad"]) {

UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityVC];

[popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

} else {

[self presentViewController:activityVC animated:YES completion:nil];

}

原文地址:www.jianshu.com/p/9cbef2d1be21

关于其他的分享参照iOS 社会化分享方案总结

相关文章

网友评论

      本文标题:pad开发中调用系统原生社会化分享

      本文链接:https://www.haomeiwen.com/subject/gvhkjxtx.html