2013-12-09 27 views
2

我有一個表格視圖。
如果我使用我的手指在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

回答

4

你的問題是高層次的,所以我會建議你可以追求高層次的方法。

1)從應用程序,你必須實現手勢識別像

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

2)這會給你座標或用戶的觸摸路徑。把它們轉換成用

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

3)用從步驟1所捕獲的路徑存儲器的位圖,通過CoreGraphics中職能借助位圖上下文。最後你會得到一個UIImage。

4)使用OCR如Tesseract從圖像中獲取文本,你應該全部設置。

祝你好運!