I am having two textfields in which if enter the text more than 100 characters I need to display the alert only when I tap onto the second textfield.Can any one suggest me how to do this.
T开发者_C百科hanks to all, Monish.
Create two UITextFields, and set their tag properties to 1 and 2 respectively. Next, implement the UITextFieldDelegate
protocol in your header file, like so;
@interface MyViewController : UIViewController <UITextFieldDelegate> {
}
And then in your implementation file, use the textFieldDidBeginEditing delegate method to check the length and display alert messages. E.g
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if (textField.tag == 2 && [self.myfirstTextField.text length] > 100) {
//-- display the alert message
}
}
精彩评论