From ca2a4ce89064be715e90ae60dc305c26e7dd5719 Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期五, 14 七月 2023 18:52:34 +0800 Subject: [PATCH] 新增 --- WanPai/Root/Course/View/CityChooseSubTypeView.swift | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/WanPai/Root/Course/View/CityChooseSubTypeView.swift b/WanPai/Root/Course/View/CityChooseSubTypeView.swift index a587f1f..364cbb5 100644 --- a/WanPai/Root/Course/View/CityChooseSubTypeView.swift +++ b/WanPai/Root/Course/View/CityChooseSubTypeView.swift @@ -10,6 +10,7 @@ class CityChooseSubTypeView: UIView,JQNibView{ @IBOutlet weak var cons_viewHeight: NSLayoutConstraint! + @IBOutlet weak var label_city: UILabel! private var closeClouse:(()->Void)? private var clouse:((String)->Void)? @@ -18,10 +19,11 @@ cons_viewHeight.constant = 100 alpha = 0 layoutIfNeeded() + startLocation() } - - - static func show(inView:UIView,afterView:UIView,clouse:@escaping (String)->Void,closeClouse:@escaping ()->Void){ + + @discardableResult + static func show(inView:UIView,afterView:UIView,clouse:@escaping (String)->Void,closeClouse:@escaping ()->Void)->CityChooseSubTypeView{ let subTypeView = CityChooseSubTypeView.jq_loadNibView() subTypeView.closeClouse = closeClouse subTypeView.clouse = clouse @@ -39,6 +41,7 @@ subTypeView.layoutIfNeeded() } } + return subTypeView } @@ -52,4 +55,19 @@ self.closeClouse!() } } + + private func startLocation(){ + locationTool.startLocation { location in + locationTool.geocoder(location) { [weak self] marks, error in + self?.label_city.text = marks?.last?.locality ?? "定位失败" + locationTool.stopLocation() + } + } errorClouse: { error in + locationTool.stopLocation() + } + } + + @IBAction func reLocationAction(_ sender: Any) { + startLocation() + } } -- Gitblit v1.7.1