提问人:Suresh Peddisetti 提问时间:12/9/2013 最后编辑:Suresh Peddisetti 更新时间:12/11/2013 访问量:212
我们如何检测和保存写在iPhone / iPad触摸屏上的文本?[关闭]
How We Detect and Save the text Which is Written on iPhone/iPad Touch Screen? [closed]
问:
我有一个表格视图。
如果我用手指在 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];
}
答:
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)从图像中获取文本,您应该已设置好。
祝你好运!
评论