GeoTag Images from image picker swift 3

前端 未结 1 528
忘掉有多难
忘掉有多难 2021-01-17 03:45

I want to get geotag location from image which is selected from image picker. I am using this code

   if picker.sourceType == UIImagePickerControllerSourceT         


        
1条回答
  •  走了就别回头了
    2021-01-17 03:57

    After hours of searching i got my ans

       import UIKit
       import Photos
    
     class ViewController: UIViewController,UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @IBOutlet weak var imageView: UIImageView!
    
    @IBOutlet weak var locationLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    
    
    @IBOutlet weak var logi: UILabel!
    
    @IBOutlet weak var lati: UILabel!
    
    
    
    
    
    var lat = String()
    var log = String()
    var location = String()
     var timeTaken = "Not Known"
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    @IBAction func imagegeo(_ sender: Any) {
    
        let imagePicker = UIImagePickerController()
        imagePicker.sourceType = .photoLibrary
        imagePicker.delegate = self
        present(imagePicker, animated: true, completion: nil)
    
    
    
    
    }
    
    
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        var chosenImage:UIImage?
    
    
    
        if let URL = info[UIImagePickerControllerReferenceURL] as? URL {
            print("We got the URL as \(URL)")
            let opts = PHFetchOptions()
            opts.fetchLimit = 1
            let assets = PHAsset.fetchAssets(withALAssetURLs: [URL], options: opts)
    
            print(assets)
    
    
            for assetIndex in 0..

    0 讨论(0)
提交回复
热议问题