[英]detect carriage return in UITextField in iOS
How would I detect a carriage return for a UITextView in iOS? 如何在iOS中检测UITextView的回车?
I am currently just watching this field for a period of time but want to improve on this a bit: 我目前只是在这个领域呆了一段时间,但想对此做些改进:
- (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;
}
So I would want to call a function after the return is found, currently I call checkText after 1 second. 所以我想在找到返回值之后调用一个函数,目前我在1秒钟后调用checkText。
Start with this: - (BOOL) textFieldShouldReturn:(UITextField *)textField
从此开始
- (BOOL) textFieldShouldReturn:(UITextField *)textField
I presume its also possible to look at the character value in the code you posted. 我认为也有可能查看您发布的代码中的字符值。 Return was int value of 13 the last time I needed to look at it directly.
上次我需要直接查看它时,返回值为int值为13。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.