开发者

problem in the textfields in iphone sdk

开发者 https://www.devze.com 2023-02-05 12:06 出处:网络
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.

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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号