Search code examples
iosuitextfielduitextfielddelegate

Why textFieldShouldBeginEditing method cannot be triggered?


I has declared in .h file

@interface TextFieldDemoViewController : UIViewController <UITextFieldDelegate>

and implements this protocol method

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
NSLog(@"OK");
return NO;
}

Build and click a textfield, but nothing happen. Did I miss something?


OK, I has resolved it: Connect textfield's Outlet 'delegate' to File's owner in IB


Solution

  • Connect textfield's Outlet 'delegate' to File's owner in IB