Sharing via UIActivityViewController to Twitter/Facebook etc. causing crash

后端 未结 5 1184
野的像风
野的像风 2020-12-06 02:10

On iOS8 I\'m using a UIActivityViewController to share a UIImage to Facebook/Twitter etc. It seemed to be working fine, but today it suddenly started crashing when running t

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-06 02:42

    Here is how I solved with swift:

        let someText:String = "shareText"
        let google:NSURL = NSURL(string:"http://google.com")!
    
        let activityViewController = UIActivityViewController(activityItems: [someText, google], applicationActivities: nil)
    
        if respondsToSelector("popoverPresentationController") {
            self.senderView.presentViewController(activityViewController, animated: true, completion: nil)
            activityViewController.popoverPresentationController?.sourceView = sender
        }else{
            senderView.presentViewController(activityViewController, animated: true, completion: nil)
        }
    

提交回复
热议问题