简体   繁体   English

Swift:如何使用扩展表添加应用程序共享功能

[英]Swift: how to add App sharing feature with Extension Sheet

I want to add the my app sharing feature in my App. 我想在我的应用程序中添加我的应用程序共享功能。 Like The Action Sheet Toggle up with the all the social Media and other app in which i can share my app Url. 像“动作表”一样,我可以在其中共享我的应用程序网址的所有社交媒体和其他应用程序。 I try to find the tutorial for that but i can't find the proper tutorial for that. 我试图找到该教程,但我找不到适合的教程。 this is what I have Done. 这就是我所做的。

func shareApp (){
     let textToShare = "Swift is awesome!  Check out this website about it!"

        if let myWebsite = NSURL(string: "http://www.google.com/") {
            let objectsToShare = [textToShare, myWebsite] as [Any]
            let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)

            activityVC.excludedActivityTypes = [UIActivityType.airDrop, UIActivityType.addToReadingList]

            self.present(activityVC, animated: true, completion: nil)
}

This What i Get. 这就是我得到的。

在此处输入图片说明

So just want to show there Some Social Media options There. 所以只想在那里显示一些社交媒体选项。

All you have done is right, except you have not added the App url of your appstore link. 您所做的一切都是正确的,只是您尚未添加appstore链接的App url。 Add that link like https://itunes.apple.com/in/app/more-customers-app/id1280868223?mt=8 and all your media will be appear in list if those application is installed in iphone. 添加该链接,例如https://itunes.apple.com/in/app/more-customers-app/id1280868223?mt=8 ,如果这些应用程序已安装在iphone中,则所有媒体都将显示在列表中。

You have got UIActivityViewController presented now, Just add in text like, 您现在已经展示了UIActivityViewController,只需添加诸如

func ShareApp()
    {
        let items:[Any] = ["Marketplace of Building Material for Architects, Interior Designers, Contractors and Home Owners. Find Material for your next project. Download  https://itunes.apple.com/in/app/more-customers-app/id1280868223?mt=8"]
        let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
        self.present(ac, animated: true)

}

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

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