0

我正在尝试为每个文本字段设置撤消和重做,并且不确定如何确定如何确定哪个文本字段是第一响应者。

是否有一个参数可以传递给工具栏按钮调用的方法,或者我需要做一些花哨的步法吗?

4

1 回答 1

1

这是一个想法:

如果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

这是对UITextFieldDelegate 协议的参考

于 2012-07-23T18:34:10.770 回答