Commit 7fefbc80 by Sarkizz

调整定位逻辑

parent e56bd550
......@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
# 名称,pod search 搜索的关键词,注意这里一定要和.podspec的名称一样,否则报错
s.name = "MRFramework"
# 版本号/库原代码的版本
s.version = "0.0.20"
s.version = "0.0.21"
# 简介
s.summary = "迈动工具库"
......
......@@ -19,6 +19,7 @@ public class MRLocation: NSObject {
/// 定位类型
public enum LocationType {
case none
case system
}
......@@ -45,7 +46,7 @@ public class MRLocation: NSObject {
let manager = CLLocationManager()
return manager
}()
private var locationType: LocationType = .system {
private var locationType: LocationType = .none {
didSet {
locationTypeDidChange()
}
......@@ -54,9 +55,12 @@ public class MRLocation: NSObject {
private var callbacks = [LocationCallback]()
private var stayCallbacks = [LocationCallback]()
override init() {}
public convenience init(type: LocationType = .system) {
self.init()
locationType = type
locationTypeDidChange()
}
}
......@@ -84,7 +88,8 @@ extension MRLocation {
if !isEnable {
return
}
let isStartLocating = authorization?(CLLocationManager.authorizationStatus()) ?? true
let authorizate = authorization?(CLLocationManager.authorizationStatus())
let isStartLocating = authorizate ?? true
if isStartLocating {
/// 存储回调
if let finish = finish {
......@@ -102,6 +107,8 @@ extension MRLocation {
systemLocation.stopUpdatingLocation()
systemLocation.startUpdatingLocation()
_status = .locating
default:
break
}
}
}
......@@ -115,6 +122,8 @@ extension MRLocation {
switch locationType {
case .system:
systemLocation.stopUpdatingLocation()
default:
break
}
}
}
......@@ -125,6 +134,8 @@ extension MRLocation {
switch locationType {
case .system:
setupSystemLocation()
default:
break
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment