gpt4 book ai didi

ios - 当用户切换应用程序的位置服务时,切换应用程序内 GPS UISwitch

转载 作者:行者123 更新时间:2023-11-30 14:17:13 24 4
gpt4 key购买 nike

这个想法是当用户从“设置”屏幕切换应用的位置服务时切换应用内 GPS 开关。

这是我的模型

func locationManager(manager:CLLocationManager!,didChangeAuthorizationStatus status: CLAuthorizationStatus){
switch status{
case .NotDetermined:
println("Not Determined!")
break
case .AuthorizedAlways: // It is being authorized always. If this is a security breach or causes
println("Authorized Always!")
NSNotificationCenter.defaultCenter().postNotificationName("GpsOn", object: nil)
self.locationManager.startUpdatingLocation() // Starts Updating Location in terms of latitude, longitude
break
case .Denied:
println("Denied!")
break
default:
println("Unhandled authorization status error")
break
}

}

和 View Controller

override func viewDidLoad() {
super.viewDidLoad()
self.initMenuWithTitle("Settings")
settingsArray = ["Filters","Notification","GPS"]
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("toggleGps:"), name: "gpsOn", object: self)

}

func toggleGps(object:AnyObject){
println("gps on")
}

最佳答案

CLLocationManager 可能就是您正在寻找的:

func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
// stuff
}

关于ios - 当用户切换应用程序的位置服务时,切换应用程序内 GPS UISwitch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30979761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com