I am working on ZBarReader and What I am having so far right now is
ZBarReaderViewController *controller = [[ZBarReaderViewController alloc] init];
controll
Yes, you have set some property first to your ZBarReaderViewController
self.zReader.showsCameraControls = NO;
self.zReader.showsZBarControls=NO;
Then you have to set your custom cameraOverlayView
, for example this set a UIToolBar
with a left button to dismiss the picker and a UISwitch
to control the flashMode:
self.zReader.cameraOverlayView=[self setOverlayPickerView];
- (UIView *)setOverlayPickerView{
UIView *v=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[v setBackgroundColor:[UIColor clearColor]];
UIToolbar *myToolBar = [[UIToolbar alloc] init];
UIBarButtonItem *backButton=[[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStyleBordered target:self action:@selector(dismissOverlayView:)];
UISwitch *sw=[[UISwitch alloc] init];
[sw setOn:NO];
UIBarButtonItem *switchButton=[[UIBarButtonItem alloc] initWithCustomView:sw];
UIBarButtonItem *fixed=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[sw addTarget:self action:@selector(handleSwitchFlash:) forControlEvents:UIControlEventValueChanged];
[myToolBar setItems:[NSArray arrayWithObjects:backButton,fixed,switchButton,nil]];
[myToolBar setBarStyle:UIBarStyleDefault];
CGRect toolBarFrame;
toolBarFrame = CGRectMake(0, 436, 320, 44);
[myToolBar setFrame:toolBarFrame];
[v addSubview:myToolBar];
return v;
}
- (void)dismissOverlayView:(id)sender{
[self dismissModalViewControllerAnimated: YES];
}
Besides @Mat answer,
should add
[self.zReader.view setFrame:[UIScreen mainScreen].bounds];
before
self.zReader.cameraOverlayView=[self setOverlayPickerView];
Because, by default, the size of self.zReader is (320, 480).
By the way, if no need compatible iOS6.0, you can just use [AVCaptureDevice]: https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVCaptureDevice_Class/Reference/Reference.html