iOS - IBAction - in which text field the user is typing
I have 2 text fields in my app and both are connected with my "devTyping" IBAction. This method (I guess it is a method) will be called when the event "editing chan开发者_运维问答ged" happens.
How can I tell my method, in which text field the user is typing?
- (IBAction)devTyping {
NSLog(@"How to know in which text field the user is typing?");
}
Take a look at this question, which should be an equivalent as to what you are asking :)
You could declare the method like this:
- (IBAction)devTyping:(UITextField*)sender {
NSLog(@"The user is typing in text field %d",sender.tag);
}
And assign each textfield a tag
in Interface Builder, which is just a number to identify the text field (or any other element).
精彩评论