为ZBarReaderViewController添加一个uibarbutton [英] add a uibarbutton for ZBarReaderViewController

查看:78
本文介绍了为ZBarReaderViewController添加一个uibarbutton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working on ZBarReader and What I am having so far right now is

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 。

My question is that can we so such things above : set toolbar visible and add button on it for ZBarReaderViewController.

推荐答案

是的,你已经为你的ZBarReaderViewController设置了一些属性

Yes, you have set some property first to your ZBarReaderViewController

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

然后你必须设置自定义 cameraOverlayView 例如,这设置了一个 UIToolBar ,用左键取消选择器,用 UISwitch 来控制flashMode: / p>

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];
}

这篇关于为ZBarReaderViewController添加一个uibarbutton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆