我们如何检测并保存iPhone/iPad触摸屏上的文字?

我们如何检测并保存iPhone/iPad触摸屏上的文字?

问题描述:

我有一个表格视图。
如果我使用我的手指在iPhone/iPod触摸屏上书写文字/文字。我们如何检测并保存iPhone/iPad触摸屏上的文字?

这里我的任务是
我们如何检测文字写在屏幕上?
也我们如何在我的表中保存文本?

实例链接:See this

其实这是我的代码写的东西对于touchBegun,touchMoved,touchEnd事件。 这工作正常。但是我如何才能完成上述任务?

- (void) touchesMoved:(NSSet *)toucheswithEvent:(UIEvent *)event { 
    NSUInteger touchCount = [touches count]; 
    NSUInteger tapCount = [[touches object] tapCount]; 
    label.text = @"touchesMoved"; 
    statusLabel.text = [NSString stringWithFormat:@"%d touches", touchCount]; 
    tapStatusLabel.text = [NSString stringWithFormat:@"%d taps", tapCount]; 
} 

- (void) touchesBegan:(NSSet *)toucheswithEvent:(UIEvent *)event { 
    NSUInteger touchCount = [touches count]; 
    NSUInteger tapCount = [[touches object] tapCount]; 
    label.text = @"touchesBegan"; 
    statusLabel.text = [NSString stringWithFormat:@"%d touches", touchCount]; 
    tapStatusLabel.text = [NSString stringWithFormat:@"%d taps", tapCount]; 
} 

- (void) touchesEnded:(NSSet *)toucheswithEvent:(UIEvent *)event { 
    NSUInteger touchCount = [touches count]; 
    NSUInteger tapCount = [[touches object] tapCount]; 
    label.text = @"touchesEnded"; 
    statusLabel.text = [NSString stringWithFormat:@"%d touches", touchCount]; 
    tapStatusLabel.text = [NSString stringWithFormat:@"%d taps", tapCount]; 
} 
+0

对不起,我编辑我的问题,我试过的代码。 – iSuresh

你的问题是高层次的,所以我会建议你可以追求高层次的方法。

1)从应用程序,你必须实现手势识别像

– touchesBegan:withEvent: 
– touchesMoved:withEvent: 
– touchesEnded:withEvent: 

2)这会给你坐标或用户的触摸路径。把它们转换成用

CGContextRef con = CGBitmapContextCreate(NULL,,rgbColorSpace, kCGImageAlphaPremultipliedFirst); 

3)用从步骤1所捕获的路径存储器的位图,通过CoreGraphics中职能借助位图上下文。最后你会得到一个UIImage。

4)使用OCR如Tesseract从图像中获取文本,你应该全部设置。

祝你好运!