How to share both Image and Text together in swift?

前端 未结 3 1652
無奈伤痛
無奈伤痛 2021-02-07 04:06

I am trying to share both image and text in swift. but when i choose to share via facebook, messenger or whatsapp it only gives text (image is not shared). I am using UIActivity

3条回答
  •  梦如初夏
    2021-02-07 04:26

    Try this This is working for me!!!

    @IBAction func btnExport(sender: AnyObject)
    {
    
        print("Export")
        let someText:String = "Hello want to share text also"
        let objectsToShare:UIImage = self.imgView.image!
        let sharedObjects:[AnyObject] = [objectsToShare,someText]
        let activityViewController = UIActivityViewController(activityItems : sharedObjects, applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view
    
        activityViewController.excludedActivityTypes = [ UIActivityTypeAirDrop, UIActivityTypePostToFacebook,UIActivityTypePostToTwitter]
    
        self.presentViewController(activityViewController, animated: true, completion: nil)
    }
    

提交回复
热议问题