I have a small iOS app and I need to execute the button action when the user presses 'Enter'.
I have found this in the apple developer site
And my question is where should I enter this
[myButton setKeyEquivalent: @ "\ r"];
Try something like this:
-
Set the
self
(current UIViewController) as the representative for your example of UITextField or UITextView:self.myTextField.delegate = self;
-
In your controller @interface the protocol
& lt; UITextFieldDelegate & gt; Do not forget to implement
. / P> -
Then apply those methods:
- (BOOL) textFieldShouldReturn: (UITextField *) Textfield {[self.myButton performSelector: @selector (MyButtonClicked object with: self.mybutton]; Yes come back } - (IBAction) myButtonClicked: (ID) sender {NSLog (@ "myButton clicked"); }
Comments
Post a Comment