1、在Info.plist中添加NSLocationWhenInUseUsageDescription和NSLocationAlwaysUsageDescription设置为YES
2、在AppDelegate中
//初始化
let vc = ViewController()
//导航控制器
let nvc = UINavigationController(rootViewController: vc)
//添加到视图
self.window?.rootViewController = nvc
3.在ViewController中导入头文件
import MapKit
import CoreLocation


4、在新创建的控制器中(TUHRViewController)
//定义一个属性
var loc = CLLocation()
网友评论