开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜