我正在尝试为每个文本字段设置撤消和重做,并且不确定如何确定如何确定哪个文本字段是第一响应者。
是否有一个参数可以传递给工具栏按钮调用的方法,或者我需要做一些花哨的步法吗?
这是一个想法:
如果viewController
成为 each 的代表textField
,那么将在 each的值更改viewController
时收到通知,或者成为第一响应者。textField
要采用委托,您将执行以下操作:
@interface MyViewController : UIViewController <UITextFieldDelegate>
@end
@implementation
- (void)someMethod{
// for a series of textfields
myTextfield1.delegate = self;
myTextfield1.delegate = self;
// or you hook the delegate in IB
}
// then you get notified
- (void)textFieldDidBeginEditing:(UITextField *)textField {
// textField here that gets passed in as an argument is the first responder
// if you have, let's say tag number for each
NSInteger activeTextFieldTag = textField.tag;
}
@end