I want to open a panel when the user clicks on a text field. I think I should use a delegate method that responds to the click event. I found that the
- (void)textDidBeginEditing:(NSNotification *)aNotification
method does not work, and that the
- (void)controlTextDidBeginEditing:(NSNotification *)aNotification
method works, but only when I edit the text in the text field, not then I click it. If I edit the text again, this method does not work. Why?
-
The
textFieldDidBeginEditing:
delegate method only gets triggered when the user starts editing the text inside theUITextField
, as the method name implies.If you want to trigger a method when the
UITextField
is touched, you should try this:[textField addTarget:self action:@selector(textFieldTouched:) forControlEvents:UIControlEventTouchDown]; - (void) textFieldTouched:(id)sender { // Display the panel }
jin : Sorry, I think I want to use this on mac , not on iphone,How to do with it with cocoa? -
The correct delegate method name is
- (void)textFieldDidBeginEditing:(UITextField *)textField
From the documentation:
This method notifies the delegate that the specified text field just became the first responder.
-
Sorry, I think I want to use this on mac , not on iphone,How to do with it with cocoa?
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.