UIView
, then, show the scanned image and text, that's all.
All I need is to use ZBarReaderView
and ZBarImageScanner
, the mainly code snippet as below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) init_camera | |
{ | |
ZBarReaderView * reader = [ZBarReaderView new]; | |
ZBarImageScanner * scanner = [ZBarImageScanner new]; | |
[scanner setSymbology:ZBAR_PARTIAL config:0 to:0]; | |
[reader initWithImageScanner:scanner]; | |
[scanner release]; | |
reader.readerDelegate = self; | |
const float h = [UIScreen mainScreen].bounds.size.height; | |
const float w = [UIScreen mainScreen].bounds.size.width; | |
const float h_padding = w / 10.0; | |
const float v_padding = h / 10.0; | |
CGRect reader_rect = CGRectMake(h_padding, v_padding, | |
w - h_padding * 2.0, h / 3.0); | |
reader.frame = reader_rect; | |
reader.backgroundColor = [UIColor redColor]; | |
[reader start]; | |
[self.view addSubview: reader]; | |
[reader release]; | |
} |
Check out the full sample from github.