Objective-C Phone 带国家代码的数字文本字段
Objective-C Phone Number Textfield with Country Code
我想创建一个带有国家代码的文本字段。用户无法更改国家/地区代码,因此代码在文本字段上必须是被动的。
有人知道吗?
enter image description here
您可以使用 Github 中的这个 Link,它会为您提供 phone 数字文本字段和精美的国家/地区代码选择器。
它为您提供委托方法,当您选择一个国家时,当 phone 号码有效或无效时,您可以获得多种格式的 phone 号码。
我用 UITextField 的左视图解决了我的问题。
供您参考,
UILabel *countryCodeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 15, theCell.textfield.frame.size.height)];
countryCodeLabel.text = @" 0090";
[countryCodeLabel sizeToFit];
theCell.textfield.leftView = countryCodeLabel;
theCell.textfield.leftViewMode = UITextFieldViewModeAlways;
我想创建一个带有国家代码的文本字段。用户无法更改国家/地区代码,因此代码在文本字段上必须是被动的。 有人知道吗?
enter image description here
您可以使用 Github 中的这个 Link,它会为您提供 phone 数字文本字段和精美的国家/地区代码选择器。
它为您提供委托方法,当您选择一个国家时,当 phone 号码有效或无效时,您可以获得多种格式的 phone 号码。
我用 UITextField 的左视图解决了我的问题。 供您参考,
UILabel *countryCodeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 15, theCell.textfield.frame.size.height)];
countryCodeLabel.text = @" 0090";
[countryCodeLabel sizeToFit];
theCell.textfield.leftView = countryCodeLabel;
theCell.textfield.leftViewMode = UITextFieldViewModeAlways;