开发者

detect carriage return in UITextField in iOS

How would I detect a carriage return for a UITextView in iOS?

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.


Start with this: - (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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜