Commit 9a5ac1b4 authored by lujunye's avatar lujunye

优化地图选择

parent 832fbb0c
......@@ -925,22 +925,22 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
var locationIsOpen = false
func checkLocation(){
if CLLocationManager.locationServicesEnabled() && CLLocationManager.authorizationStatus() == .authorizedAlways || CLLocationManager.authorizationStatus() == .authorizedWhenInUse{
// if CLLocationManager.locationServicesEnabled() && CLLocationManager.authorizationStatus() == .authorizedAlways || CLLocationManager.authorizationStatus() == .authorizedWhenInUse{
locationIsOpen = true
}else if CLLocationManager.authorizationStatus() == .denied {
let aleat = UIAlertController(title: "打开定位开关", message:"定位服务未开启,请进入系统设置>隐私>定位服务中打开开关,并允许商户端使用定位服务", preferredStyle: .alert)
let tempAction = UIAlertAction(title: "取消", style: .cancel) { (action) in
}
let callAction = UIAlertAction(title: "立即设置", style: .default) { (action) in
let url = NSURL.init(string: UIApplication.openSettingsURLString)
if(UIApplication.shared.canOpenURL(url! as URL)) {
UIApplication.shared.openURL(url! as URL)
}
}
aleat.addAction(tempAction)
aleat.addAction(callAction)
self.present(aleat, animated: true, completion: nil)
}
// }else if CLLocationManager.authorizationStatus() == .denied {
// let aleat = UIAlertController(title: "打开定位开关", message:"定位服务未开启,请进入系统设置>隐私>定位服务中打开开关,并允许商户端使用定位服务", preferredStyle: .alert)
// let tempAction = UIAlertAction(title: "取消", style: .cancel) { (action) in
// }
// let callAction = UIAlertAction(title: "立即设置", style: .default) { (action) in
// let url = NSURL.init(string: UIApplication.openSettingsURLString)
// if(UIApplication.shared.canOpenURL(url! as URL)) {
// UIApplication.shared.openURL(url! as URL)
// }
// }
// aleat.addAction(tempAction)
// aleat.addAction(callAction)
// self.present(aleat, animated: true, completion: nil)
// }
}
override func viewDidLoad() {
......@@ -1442,7 +1442,10 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
vc.idx = indexPath.row
vc.adrDatasArr = self.adrDatas
vc.delegate = self
if self.loc != nil {
vc.lat = self.loc.lat_lon?.lat as! CLLocationDegrees
vc.lng = self.loc.lat_lon?.lon as! CLLocationDegrees
}
if self.adrArr.count > indexPath.row {
let dict = self.adrArr[indexPath.row] as! NSDictionary
......@@ -1467,6 +1470,10 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
vc.idx = indexPath.row
vc.adrDatasArr = adrDatas
vc.delegate = self
if self.loc != nil {
vc.lat = self.loc.lat_lon?.lat as! CLLocationDegrees
vc.lng = self.loc.lat_lon?.lon as! CLLocationDegrees
}
if adrArr.count > indexPath.row {
let dict = adrArr[indexPath.row] as! NSDictionary
......
......@@ -172,6 +172,10 @@ class CityListViewController: BaseViewController ,UITableViewDelegate,UITableVie
}
@IBAction func back(_ sender: Any) {
if locLbl.text == "未定位" {
HUD.flash(.label("请选择城市"), delay: 1.2)
return
}
self.navigationController?.popViewController(animated: true)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......
......@@ -90,7 +90,6 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
lat = location.latitude as! CLLocationDegrees
lng = location.longitude as! CLLocationDegrees
mapView.setCenter(location, animated: false)
}
......@@ -100,7 +99,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
let vc = CityListViewController()
vc.adrDatas = adrDatasArr!
vc.locatStr = "未定位"
if cityName.length != 0 || cityName != nil{
if cityName.length != 0{
vc.locatStr = cityName as String
}
vc.delegate = self
......
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 to comment