iOS8定位

作者: ForeverYoung21 | 来源:发表于2015-05-27 10:31 被阅读92次
        Info.plist 增加一条 NSLocationWhenInUseUsageDescription-String-提示信息
    

       override func viewDidAppear(animated: Bool) {
            super.viewDidAppear(animated)
    
            self.checkLocationAuthorizationStatus()
        }
    
        func checkLocationAuthorizationStatus() {
            if CLLocationManager.authorizationStatus() == .AuthorizedWhenInUse {
                self.mapView.showsUserLocation = true  //使用前需要进行授权检查
            } else {
                self.locationManager.requestWhenInUseAuthorization()
            }    
        }

    相关文章

      网友评论

        本文标题:iOS8定位

        本文链接:https://www.haomeiwen.com/subject/iburqttx.html