Commit 248d5f38 authored by lujunye's avatar lujunye

阿斯顿发卡死;阿斯顿发了;撒点

parent eaf854fe
...@@ -50,7 +50,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -50,7 +50,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
initMapView(lat: coo.latitude, lng: coo.longitude) initMapView(lat: coo.latitude, lng: coo.longitude)
initSearch() initSearch()
// initUI() // initUI()
} }
func backAction() { func backAction() {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
...@@ -88,8 +88,52 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -88,8 +88,52 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
manger.startUpdatingLocation() manger.startUpdatingLocation()
manger.requestAlwaysAuthorization() manger.requestAlwaysAuthorization()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardShow(note:)), name:UIResponder.keyboardWillShowNotification,object: nil)
// 监听键盘隐藏通知
NotificationCenter.default.addObserver(self,selector: #selector(keyboardHidden(note:)),
name: UIResponder.keyboardWillHideNotification, object: nil)
}
//键盘弹出监听
@objc func keyboardShow(note: Notification) {
guard let userInfo = note.userInfo else {return}
guard let keyboardRect = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else{return}
//获取动画执行的时间
var duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double
if duration == nil { duration = 0.25 }
var btmH = 255
if IS_IPHONE_X {
btmH = 289
}
//获取键盘弹起的高度
print(keyboardRect.height)
btmView.snp.updateConstraints { (make) in
make.bottom.equalTo(-keyboardRect.height)
make.left.right.equalTo(0)
make.height.equalTo(btmH)
}
}
@objc func keyboardHidden(note: Notification){
var btmH = 255
if IS_IPHONE_X {
btmH = 289
}
//获取键盘弹起的高度
btmView.snp.updateConstraints { (make) in
make.bottom.equalTo(0)
make.left.right.equalTo(0)
make.height.equalTo(btmH)
}
} }
deinit {
//记得要取消键盘通知的监听
NotificationCenter.default.removeObserver(self)
}
//MARK: - 自定义delegate //MARK: - 自定义delegate
func clearSearchAction() { func clearSearchAction() {
print("清楚搜索文字") print("清楚搜索文字")
...@@ -110,9 +154,9 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -110,9 +154,9 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
@objc func backToCenter(){ @objc func backToCenter(){
mapView.setCenter(CLLocationCoordinate2DMake(lat, lng), animated: false) mapView.setCenter(CLLocationCoordinate2DMake(lat, lng), animated: false)
} }
// @objc func backAction(){ // @objc func backAction(){
// self.navigationController?.popViewController(animated: true) // self.navigationController?.popViewController(animated: true)
// } // }
@objc func submitAction(){ @objc func submitAction(){
if adrStr != nil { if adrStr != nil {
...@@ -240,7 +284,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -240,7 +284,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
listView = tbv listView = tbv
var btnH = 49 var btnH = 49
if IS_IPHONE_X { if IS_IPHONE_X {
btnH = 83 btnH = 83
} }
tbv.snp.makeConstraints { (make) in tbv.snp.makeConstraints { (make) in
make.top.left.right.equalTo(0) make.top.left.right.equalTo(0)
...@@ -276,8 +320,9 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -276,8 +320,9 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
} }
} }
let locationM = AMapLocationManager() let locationM = AMapLocationManager()
var btmView = UIView()
func initMapView(lat:CLLocationDegrees,lng:CLLocationDegrees) { func initMapView(lat:CLLocationDegrees,lng:CLLocationDegrees) {
let btmView = UIView()
self.view.addSubview(btmView) self.view.addSubview(btmView)
var btmH = 255 var btmH = 255
if IS_IPHONE_X { if IS_IPHONE_X {
...@@ -307,7 +352,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -307,7 +352,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
img.image = UIImage() img.image = UIImage()
} }
} }
let tap = UITapGestureRecognizer(target: self, action: #selector(cancelKeyboard)) let tap = UITapGestureRecognizer(target: self, action: #selector(cancelKeyboard))
mapView.addGestureRecognizer(tap) mapView.addGestureRecognizer(tap)
...@@ -321,7 +366,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag ...@@ -321,7 +366,7 @@ class SJMapViewController: UIViewController,NavBarViewDelegate,AMapLocationManag
make.bottom.equalTo(btmView.snp_top).offset(-13.5) make.bottom.equalTo(btmView.snp_top).offset(-13.5)
} }
} }
func initSearch() { func initSearch() {
search = AMapSearchAPI() search = AMapSearchAPI()
search.delegate = self search.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