tags:

views:

41

answers:

1

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.

+1  A: 

Have you tried sending the resignFirstResponder message?

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
     [textField resignFirstResponder];
     return YES;
}
arul
i send [textField resignFirstResponder] inside textFieldShouldReturn. But the delegate method itself not firing while i tapping return button.
diana
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
You need to post entire code.
arul