在iOS的UITextField中检测回车



我如何检测在iOS中的UITextView回车?

我目前正在观察这个领域一段时间,但希望在这一点上有所改进:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSLog(@"text editing started: %i", scanning);
    if (!scanning) {
        timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(checkText:) userInfo:nil repeats:NO];
        scanning = YES;
        [self.scannedItems scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
    }
    return YES;
}

所以我想在返回后调用一个函数,目前我在1秒后调用checkText。

从这个开始:- (BOOL) textFieldShouldReturn:(UITextField *)textField

我认为它也可以看看你发布的代码中的字符值。当我最后一次需要直接查看它时,返回的是int值13

最新更新