在代理方法中, 判斷UITextField/UITextView字?jǐn)?shù)總是不正確
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
通過(guò)對(duì)TextField/View監(jiān)聽(tīng)事件能準(zhǔn)確獲取字?jǐn)?shù), 在回調(diào)方法中處理按鈕考慮蝙寨、是否可點(diǎn)等動(dòng)作
[self.mobileTextField addTarget:self action:@selector(textValueDidChanged) forControlEvents:UIControlEventEditingChanged];
//Action方法
- (void)textValidChanged
{
self.verificationCodeButton.enabled = NO;
self.submitButton.enabled = NO;
self.submitButton.enabled = (self.mobileTextField.text.length >= 11) && (self.VerificationCodeTextField.text.length > 0);
self.verificationCodeButton.enabled = self.mobileTextField.text.length >= 11;
self.verificationCodeButton.backgroundColor = self.verificationCodeButton.enabled ? QDYellowColor : ButtonGrayColor;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者