How to share my current location to UIActivityViewController?

前端 未结 8 1371
别那么骄傲
别那么骄傲 2020-12-05 12:32

I know i can add things like text, URL, images to UIActivityViewController , but how to add my current location with a thumbnail of my location like in the tweet shown below

8条回答
  •  萌比男神i
    2020-12-05 12:42

    I've updated @naturaln0va's answer to Swift 3:
    https://gist.github.com/ElegyD/510a17904917a7e7326254b824da1b2f

    Just copy & paste somewhere and use it like so:

    let coordinate = CLLocationCoordinate2D(latitude: 52.520007, longitude: 13.404954)
    let vCardURL = LocationVCard.vCardUrl(from: coordinate, with: "Berlin")
    let activityViewController = UIActivityViewController(activityItems: [vCardURL], applicationActivities: nil)
    present(activityViewController, animated: true, completion: nil)
    

提交回复
热议问题