简体   繁体   English

向iOS应用添加共享扩展程序

[英]Add a share extension to an iOS app

Let me preface this by saying I'm a relatively novice programmer and have even less experience thinking about iOS. 首先,请允许我说我是一个相对较新的程序员,对iOS的经验甚至更少。 I'm looking for some information about how to access the sharing aspects of the iPhone. 我正在寻找有关如何访问iPhone共享方面的一些信息。 Unfortunately, I don't think my Google queries were using the proper terminology so let me elaborate. 不幸的是,我认为我的Google查询没有使用正确的术语,所以让我详细说明一下。

I was looking at the FT website and noticed that when I clicked to share the document, there was a toolbar that popped up with the apps that are able to share. 我在浏览FT网站时发现,当我单击共享文档时,会弹出一个工具栏,其中包含可以共享的应用程序。 First question is if I'm trying to make an app, how do I make the app accessible on this toolbar? 第一个问题是,如果我要创建一个应用程序,该如何在此工具栏上使该应用程序可访问?

共享工具栏

Next question. 下一个问题。 When I clicked Evernote the app seemed to automatically parse the title, put that in the text box, and also if you look to the very right of the screenshot, you can vaguely see a box which contains a link to the website. 当我单击Evernote时,该应用程序似乎会自动解析标​​题,将其放在文本框中,并且如果您查看屏幕快照的右侧,您也可以隐约看到一个包含网站链接的框。 I would love to grab this information and save it to a database. 我想获取这些信息并将其保存到数据库中。 Do you happen to know where I could find guidance for doing something like that? 您是否知道我在哪里可以找到有关这样做的指导?

Evernote分享

Any help would be most appreciated. 非常感激任何的帮助。

You simply add the title, link, image, whatever you're making the user share to your share viewController, then add it as an array to the controller, it's very simple, other options you've is to exclude some of the services you don't want the user to share to, etc. 您只需将标题,链接,图像等与用户共享的内容添加到共享viewController中,然后将其作为数组添加到控制器中,这非常简单,您要做的其他选择是排除某些服务不想用户共享,等等。

    let firstItem = "Share it now"
    let secondItem = generatedImageOrWhatSoEver


    let shareController = UIActivityViewController(activityItems: [firstItem, secondItem], applicationActivities: nil)
    self.presentViewController(shareController, animated: true, completion: nil)

hope this's what you're looking for. 希望这就是您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM