Commit 420d5f69 authored by pete谢兆麟's avatar pete谢兆麟

电话号码限制

parent f34e62b4
...@@ -21,6 +21,7 @@ class YHCompanyViewModel: YHBaseViewModel { ...@@ -21,6 +21,7 @@ class YHCompanyViewModel: YHBaseViewModel {
let params = ["company_name":key,"page_size":20,"current_page":1] as [String : Any] let params = ["company_name":key,"page_size":20,"current_page":1] as [String : Any]
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in
// let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象 //1. json字符串 转 对象
guard self != nil else { return } guard self != nil else { return }
if json.code == 200 { if json.code == 200 {
......
...@@ -61,6 +61,7 @@ class YHPhoneMessageView: UIView { ...@@ -61,6 +61,7 @@ class YHPhoneMessageView: UIView {
text.textAlignment = .left text.textAlignment = .left
text.keyboardType = .phonePad text.keyboardType = .phonePad
text.clearButtonMode = .always text.clearButtonMode = .always
text.delegate = self
text.addTarget(self, action: #selector(textFeildChange), for: .allEvents) text.addTarget(self, action: #selector(textFeildChange), for: .allEvents)
return text return text
}() }()
...@@ -84,3 +85,17 @@ class YHPhoneMessageView: UIView { ...@@ -84,3 +85,17 @@ class YHPhoneMessageView: UIView {
} }
} }
} }
extension YHPhoneMessageView: UITextFieldDelegate {
func textFieldDidEndEditing(_ textField: UITextField) {
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
var newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
if newText.count > 11 {
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