UIActivityViewController

Sharing things using iOS uses a standard, powerful component that other apps can plug into. As a result, it should be your first port of call when adding sharing to an app. This component is called UIActivityViewController: you tell it what kind of data you want to share, and it figures out how best to share it.

As we're working with images, UIActivityViewController will automatically gives us functionality to share by iMessage, by email and by Twitter and Facebook, as well as saving the image to the photo library, assigning it to contact, printing it out via AirPrint, and more. It even hooks into AirDrop and the iOS 8 extensions system so that other apps can read the image straight from us.

Best of all, it takes just a handful of lines of code to make it all work. But before we touch UIActivityViewController, we first need to give users a way to trigger sharing, and the way we're going to use is to add a bar button item.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 之前没课的时候,抱怨着想要回家,负能量满满。如今,有一点点看得见的光明,瞬间照亮了我的心。 昨晚,去锦绣半岛那边派...
    减肥的女孩阅读 272评论 0 1
  • “总感觉少了点什么。”我茫然的站在街上,放眼望去,现在的街道已经没有了街道本该有的气息了。整个街道死气沉沉的,来来...
    信念_372d阅读 485评论 0 0
  • 不错的参考: Enum进阶 使用enum创建枚举,像类和其他所有类型那样,枚举可以有方法,供访问。 再看一个枚举...
    HunterDude阅读 214评论 0 1
  • 忆如尘老师介绍了和人品牌对她的影响最大的是“表里如一”。潘泠竹老师的最大特点是认真极致,表达精简、完整。关键时刻有...
    aseeya阅读 289评论 0 0
  • 从小到大我们一直处于周遭的人和事的环境中,每一个瞬间都能让我们感受到些什么,是开心的还是伤心的,是平和的还是激动的...
    ShirleyFang阅读 179评论 0 0

友情链接更多精彩内容