开发者

iOS - IBAction - in which text field the user is typing

开发者 https://www.devze.com 2023-02-22 21:20 出处:网络
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.

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消