-
地理位置授权,获取经纬度
var locManager : CLLocationManager!
var currentLatitude : Double! = nil
var currentLongitude : Double! = nil
locManager = CLLocationManager()
locManager.delegate = self
locManager.desiredAccuracy = kCLLocationAccuracyBest
locManager.distanceFilter = 5.0
locManager.startUpdatingLocation()
locManager.distanceFilter = 1000.0
if locManager.respondsToSelector(#selector(CLLocationManager.requestAlwaysAuthorization)){
locManager.requestAlwaysAuthorization() // 永久授权
locManager.requestWhenInUseAuthorization() //使用中授权
}
currentLatitude = locManager.location?.coordinate.latitude
currentLongitude = locManager.location?.coordinate.longitude
print("(currentLatitude)","(currentLongitude)") -
第一次启动app进入引导页,以后都进入启动页
if !(NSUserDefaults.standardUserDefaults().boolForKey("firstLaunch") ){ //这里判断是否第一次 print("第一次启动") NSUserDefaults.standardUserDefaults().setBool(true, forKey:"firstLaunch") //如果是第一次启动的话,使用guideViewController (用户引导页面) 作为根视图 let one_vc = guideViewController(nibName:nil,bundle: nil) //创建导航控制器 let nvc = UINavigationController(rootViewController:one_vc) //设置根视图 self.window!.rootViewController = nvc }else{ print("不是第一次启动") //加载启动页控制器 let Start = StartPageViewController(nibName:nil,bundle: nil) //创建导航控制器 let nvc = UINavigationController(rootViewController:Start) //设置根视图 self.window!.rootViewController = nvc }










网友评论