2

我正在研究 ZBarReader,到目前为止我所拥有的是

ZBarReaderViewController *controller = [[ZBarReaderViewController alloc] init];
controller.navigationController.navigationBarHidden = NO;
// Add Edit button to the right and handle click event UIBarButtonItem *manualButton = [[UIBarButtonItem alloc] initWithTitle:@"Manual" style:UIBarButtonItemStyleBordered target:self action:@selector(EditMode:)];
[controller.navigationItem setRightBarButtonItem:manualButton];
controller.readerDelegate = self;
[self presentModalViewController:controller animated:YES];

我的问题是我们可以在上面做这样的事情:设置工具栏可见并在其上为 ZBarReaderViewController 添加按钮。

4

2 回答 2

8

是的,您首先为您的 ZBarReaderViewController 设置了一些属性

 self.zReader.showsCameraControls = NO;
 self.zReader.showsZBarControls=NO;

然后你必须设置你的 custom cameraOverlayView,例如这个UIToolBar用左键设置一个来关闭选择器和一个UISwitch来控制 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];
}
于 2012-04-13T20:16:35.967 回答
0

除了@Mat 答案,应该在 [self.zReader.view setFrame:[UIScreen mainScreen].bounds]; 之前 添加self.zReader.cameraOverlayView=[self setOverlayPickerView];

因为,默认情况下,self.zReader 的大小是 (320, 480)。

顺便说一句,如果不需要兼容iOS6.0,你可以使用[AVCaptureDevice]:https ://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVCaptureDevice_Class/Reference/Reference.html

于 2014-09-04T01:06:28.743 回答