0

In my view controller i added a text field as below.

txt1 = [[UITextField alloc]initWithFrame:CGRectMake(10, 10, 70, 20)];
txt1.delegate = self;
txt1.borderStyle = UITextBorderStyleRoundedRect;
[self.view addSubview:txt1];
[txt1 release];

I set UITextFieldDelegate in .h file. I write

-(BOOL)textFieldShouldReturn:(UITextField *)textField 

to dissmiss my keyboard.But it not firing delegate method. Any help!!! Thanks in advance.

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
diana
  • 427
  • 2
  • 10
  • 22

1 Answers1

1

Have you tried sending the resignFirstResponder message?

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
     [textField resignFirstResponder];
     return YES;
}
arul
  • 13,998
  • 1
  • 57
  • 77
  • i send [textField resignFirstResponder] inside textFieldShouldReturn. But the delegate method itself not firing while i tapping return button. – diana Sep 21 '09 at 10:11
  • I did the same in AppllicationDelegate. Here i added the textfield in window. It is working. What is the reason behind that. Any idea? – diana Sep 21 '09 at 10:14