TEL:400-8793-956
当前位置:程序、服务器

我想获得iPhone的API密钥坐标。请帮忙

提问者: 近期获赞: 浏览人数: 发布时间:2021-02-24 09:12:00

 问:所以我想获取iPhone(模拟器)的坐标,但是每次都会给我一个错误。有人可以告诉我很好的代码(Swift 2.0,Xcode 7.0.1)预先感谢。

 
 
答:import  UIKit 
import  CoreLocation
类ViewController :UIViewController ,CLLocationManagerDelegate {让locationManager = CLLocationManager ()覆盖func viewDidLoad (){ super 。viewDidLoad ()locationManager 。委托=自我locationManager 。neededAccuracy = kCLLocationAccuracyBest locationManager 。requestWhenInUseAuthorization ()locationManager 。
 
        startUpdatingLocation ()
}覆盖FUNC didReceiveMemoryWarning (){超级。didReceiveMemoryWarning ()//处理任何可以重新创建的资源。} func locationManager (管理器:CLLocationManager ,didUpdateLocations位置:[ CLLocation ]){ } func locationManager (管理器:CLLocationManager ,didFailWithError错误:NSError ){
          
        打印(“错误:”  + 错误。localizedDescription )
} }    
 
上一篇: 另一个null指针异常-DayAdapter ConvertView为null
下一篇: 按照“在Mac上安装Treehouse VM”视频进行了05:14的操作,但无法通过