Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shouldChangeCharactersInRange method not called after calling becomeFirstResponder

Hi i am new to the iOS,

i am using several text fields in my project, so i want use becomeFirstResponder for editing done for any one of text field. it is working fine in xcode 3.2.5 but it makes problem in xcode 4.2.1

In xcode 4.2.1 after calling the becomeFirstResponder i could not edit the text field, it is showing the virtual key board i could tap the keys but tapped keys are not entered in text field.

Please help me out.

like image 557
thavasidurai Avatar asked Dec 09 '22 21:12

thavasidurai


1 Answers

Firstly add this delegates in interface:

 @interface yourViewController : UIViewController<UITextFieldDelegate>

If using from xib then right click on UITextField and bind delegate with fileowner else add this code in viewDidLoad's method.

  yourTextField.delegate = self;

Add UITextField's delegate and it will be called

 - (BOOL)textFieldShouldReturn:(UITextField *)textField //resign first responder for textfield 
 {
    [textField resignFirstResponder];
    return YES;
 }

 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
 {
   return YES;
 }
like image 70
Paresh Navadiya Avatar answered May 16 '23 05:05

Paresh Navadiya