0

我有一个 UITextField 我为所有类型的事件添加了一个动作

[textField addTarget:self action:@selector(log:)forControlEvents:UIControlEventAllTouchEvents];

现在在日志中:方法我想输出事件名称

- (void)log:(id)sender {
 NSLog(@"%@",event);
}
4

1 回答 1

3

代替:

[textField addTarget:self action:@selector(log:)forControlEvents:UIControlEventAllTouchEvents];

利用:

[textField addTarget:self action:@selector(log:event:)forControlEvents:UIControlEventAllTouchEvents];

并使用两个参数实现操作方法:(id)sender(UIEvent *)event

- (void)log:(id)sender event:(UIEvent *)event
于 2013-05-31T19:56:40.927 回答