我们如何检测和保存写在iPhone / iPad触摸屏上的文本?[关闭]

How We Detect and Save the text Which is Written on iPhone/iPad Touch Screen? [closed]

提问人:Suresh Peddisetti 提问时间:12/9/2013 最后编辑:Suresh Peddisetti 更新时间:12/11/2013 访问量:212

问:


要求代码的问题必须表现出对所解决问题的最低限度的理解。包括尝试的解决方案、它们不起作用的原因以及预期的结果。Смотритетакже: Stack Overflow 问题清单

9年前关闭。

我有一个表格视图。
如果我用手指在 iPhone/iPod 触摸屏上写一个单词/文本。

我的任务是
:我们如何检测屏幕上写的文本?
还有我们如何将该文本保存在我的表格中?

示例链接:查看此内容

实际上,这是我为 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];
}
iOS的 iPhone iPad iOS4

评论

0赞 Suresh Peddisetti 12/10/2013
对不起,我用我尝试过的代码编辑我的问题。

答:

4赞 TorukMakto 12/9/2013 #1

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

1)在应用程序中,您必须实现手势识别器,例如

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

2)这将为您提供用户触摸的坐标或路径。将它们转换为内存位图使用

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

3) 使用从步骤 1 捕获的路径,通过 CoreGraphics 函数绘制位图上下文。最后,你会得到一个UIImage。

4)使用OCR(例如Tesseract)从图像中获取文本,您应该已设置好。

祝你好运!