Commit 4211ecc2 authored by David黄金龙's avatar David黄金龙

Merge branch 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into youhua-dev

* 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  //  学校名称搜索bug修复
parents ee528e54 6cf62c3e
......@@ -14,7 +14,6 @@ class YHCollegeSearchViewController: YHBaseViewController {
var searchCollegeName:String?
var selectBlock:((String?)->Void)?
var colleges:[YHCollegeInfo] = []
var lastSearchTime:TimeInterval = 0.0
let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel()
lazy var searchBar: YHCollegeSearchBar = {
......@@ -91,10 +90,7 @@ class YHCollegeSearchViewController: YHBaseViewController {
[weak self] text in
guard let self = self else { return }
searchCollegeName = text
if Date().timeIntervalSince1970 - lastSearchTime >= 1.0 {
lastSearchTime = Date().timeIntervalSince1970
searchCollege()
}
self.searchCollege()
}
searchBar.confirmBlock = {
[weak self] in
......
......@@ -273,8 +273,6 @@ class YHEducationRequestViewModel {
// 搜索学校
func searchCollegeInfoList(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.searchCollegeNameApi
let _ = YHNetRequest.getRequest(url: strUrl, params:params) {[weak self] json, code in
......
......@@ -8,7 +8,7 @@
import UIKit
class YHCollegeSearchBar: UIView {
class YHCollegeSearchBar: UIView, UITextFieldDelegate {
static let height = 40.0
static let confirmBtnHeight = height-8.0
......@@ -37,7 +37,7 @@ class YHCollegeSearchBar: UIView {
textField.font = UIFont.PFSC_M(ofSize: 12)
textField.tintColor = UIColor.brandMainColor
textField.textColor = UIColor.mainTextColor
textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged)
textField.delegate = self
return textField
}()
......@@ -97,12 +97,19 @@ class YHCollegeSearchBar: UIView {
}
}
@objc func textFieldChanged(textField:UITextField) {
func textFieldDidChangeSelection(_ textField: UITextField) {
let text = textField.text ?? ""
let max = 100
textField.text = (text.count > max ? text[safe: ..<max] : text)
if let textChange = textChange {
textChange(textField.text)
textChange?(textField.text)
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if string.count > 0 {
let newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
if newText.count > 100 {
return false
}
}
return true
}
}
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