【发布时间】:2015-06-17 15:19:17
【问题描述】:
我正在尝试在使用应用程序时请求用户的位置。我已将 NSLocationWhenInUseUsage 添加到我的 plist 中。该应用程序不会崩溃或以其他方式显示任何错误。该应用程序刚刚启动,没有任何弹出请求用户许可。
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
@IBOutlet weak var map: MKMapView!
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.requestWhenInUseAuthorization()
我还在我的代码中添加了这个函数:
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
println(locations)
另外,我不是一个熟练的程序员,所以更简单的答案会更好。
【问题讨论】:
标签: swift dictionary ios8 xcode6