crash in textFieldShouldReturn
[<MyViewController> _clearBecomeFirstResponderWhenCapable] -- NSInvalidArgumentException Unrecognized selector sent to instance
What is _clearBecomeFirstResponder?
I am creating a couple of views manually in my viewcontroller - On the similar lines of UICatalog. I create a text field and set my view controller as delegate.
Here's the code
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
// setup our parent content view and embed it to your view controller
UIView *contentView = [[UIView alloc] initWithFrame:screenRect];
contentView.backgroundColor = [UIColor colorWithRed:.56 green:.071 blue:.067 alpha:1];//[UIColor blackColor];
//loginTableView.backgroundColor = [UIColor colorWithRed:.56 green:.071 blue:.067 alpha:1];
contentView.autoresizesSubviews = YES;
contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.view = contentView;
[contentView release];
// create the UITextField
refTextField = [[UITextField alloc] initWithFrame:textFrame];
// set the various properties here
.....
// now add the text field to the view
[self.view addSubview:refTextField];
refTextField.delegate = self;
Is there something I am missing? I've set the proper delegate and implemented this protocol method
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if ( textField == refTextField ) {
NSLog(@"came to delegate method for UITextFieldDelegate");
[self resignFirstResponder];
}
return YES;
}
But when I click the return button, the above error comes.
Thanks in advance.
iMac, Mac OS X (10.5.4)