У меня возникла проблема, когда я кодировал webView для отображения моего собственного веб-сайта: я не мог позволить получить свое текущее местоположение в виде чисел.Как разрешить текущее местоположение с помощью webView?
Я открыл все разрешения, чтобы местоположение, и в противном случае мое местоположение работает на всех устройствах, но прошивкой 10.
Должен ли я делать какие-либо новые разрешения, чтобы позволить мне получить текущее местоположение?
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate
{
@IBOutlet weak var webview: UIWebView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.requestAlwaysAuthorization()
self.locationManager.startUpdatingLocation()
let url = NSURL (string: "http://my-website");
let requestObj = NSURLRequest(url: url! as URL);
webview.loadRequest(requestObj as URLRequest);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}