未获得位置iOS8的授权

时间:2015-08-23 17:06:27

标签: ios swift location cllocationmanager

我已尝试查看其他解决方案,例如:requestWhenInUseAuthorization() not Work in iOS 8 With NSLocationWhenInUseUsageDescription Key in Info.plist

但我无法获得授权以获取位置。

那个人在另一个问题上的问题是他在viewDidLoad内有经理,我没有,但仍然没有出现授权提示。我已经更新了我的plist:

gyazo.com/b66946b9976aa226a21c0bf6e3817e3a

让我的经理在我的viewDidLoad之外:

import UIKit
import AVFoundation
import MapKit

class SecondViewController: UIViewController, CLLocationManagerDelegate {

let locationManager: CLLocationManager = CLLocationManager()


var player = AVPlayer()
override func viewDidLoad() {
    super.viewDidLoad()
    self.locationManager.delegate = self
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
    self.locationManager.requestWhenInUseAuthorization()
    self.locationManager.startUpdatingLocation()
    println("Got to end of locationmanager")
    //playentryaudio() // User plugged in mic -- start playing entry audio.
}

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    println("Got to locationmngsr")
    var userlocation = locations[0] as! CLLocation

    var latitude: CLLocationDegrees = userlocation.coordinate.latitude

    var longitude: CLLocationDegrees = userlocation.coordinate.longitude

    println(latitude)
    println(longitude)
} //snip rest of code

由于它没有获得身份验证,因此它永远不会访问locationManager功能。

0 个答案:

没有答案