我可能错过了一些东西......首先,我继承UITextField
了一个 Tap 手势识别器并将其添加到UITextField
(在指定的初始化程序中):
UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pressed:)];
[self addGestureRecognizer:ges];
-(void)pressed:(id)sender
{
didPressed = YES;
[self becomeFirstResponder];
}
然后我将我的 viewController 设置为 textField 委托并实现了这个:
- (BOOL)textField:(UIOneLetterTextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSLog(@"Key Pressed %@", string);
textField.text = string;
[textField resignFirstResponder];
UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc] initWithTarget:textField action:@selector(pressed:)];
[textField addGestureRecognizer:ges];
[self gotoNextTextfield:textField.cellLoc];
return NO;
}
从这一点开始,由于某种原因,pressed:
在点击 textField 时不会被调用。任何想法为什么?