http://blog.isana.net/2014/08/ios.html 上記サイトのサンプルコードをそのままコピーしたのですが、以下のエラーが出てしまうのですがなぜでしょうか。 No visible @interface for "UIView" declares the selector "setImage" 下記コードの、// イメージビューに画像をセットとコメントしてある部分です。回答をお願いします // 中略 // カメラボタン押下 - (IBAction)tappedCamera:(id)sender { UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; // デリゲート指定 [imagePickerController setDelegate:self]; // トリミング指定 [imagePickerController setAllowsEditing:YES]; // カメラの使用有無を確認 if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) { // カメラを指定 [imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera]; } else { // アルバムを指定 [imagePickerController setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum]; } // コントローラ起動 [self presentViewController:imagePickerController animated:YES completion:nil]; } // コントローラ終了 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // イメージをメモリに保存 self.selectedImage = [info objectForKey:UIImagePickerControllerEditedImage]; // イメージビューに画像をセット [self.imageView setImage:self.selectedImage]; // 親ビューへ戻る [self dismissViewControllerAnimated:YES completion:nil]; // テキストを空に [self.textView setText:nil]; // インジケータ開始 UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; spinner.center = CGPointMake(160, 240); spinner.hidesWhenStopped = YES; [self.view addSubview:spinner]; [spinner startAnimating]; // OCR実行 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // 英語 : eng を設定 (日本語の場合は jpn を指定) Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng"]; // OCRを実行する画像を設定 [tesseract setImage:self.selectedImage]; // OCR実行 [tesseract recognize]; // 実行結果をアラートビューで表示 dispatch_async(dispatch_get_main_queue(), ^{ // 結果をテキストビューに指定 [self.textView setText:[tesseract recognizedText]]; // インジケータ停止 [spinner stopAnimating]; }); }); }
↧