Zbar cameraOverlay UIBarItem单击不起作用

时间:2011-12-28 15:02:28

标签: iphone uibarbuttonitem uitoolbar zbar-sdk

我已经关注在iPad上运行的代码,我在Zbar 1.2.2 beta版本中使用iPad支持。

ZBarReaderViewController* mReader = [[ZBarReaderViewController alloc] init];
mReader.readerDelegate = self;
mReader.showsZBarControls = NO;
mReader.wantsFullScreenLayout = NO;
mReader.readerView.frame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height);
UIButton *imageView = [[UIButton alloc] init];
imageView.frame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height);
[self setupToolBar:imageView];
mReader.cameraOverlayView = imageView;

setupToolBar跟随

- (void)setupToolBar:(UIButton*)imageView
{
    [imageView retain];
    UIToolbar* imagePickerToolBar = [[UIToolbar alloc] init];

    UIImage *c = [UIImage imageNamed:@"close.png"];
    UIBarButtonItem *closeItem = [[UIBarButtonItem alloc] initWithImage:c style:UIBarButtonItemStylePlain target:self action:@selector(closeBarItemPressed:)];
    NSArray *items = [NSArray arrayWithObjects: closeItem, nil];

    [imagePickerToolBar setItems:items animated:NO];

    imagePickerToolBar.frame = CGRectMake(0, UIScreen.mainScreen.bounds.size.height - imagePickerToolBar.frame.size.height, imagePickerToolBar.frame.size.width, imagePickerToolBar.frame.size.height); 

    [imageView addSubview:imagePickerToolBar];
    [imageView bringSubviewToFront:imagePickerToolBar];

    [imagePickerToolBar release];
    [closeItem release];    
    [imageView release];
}

现在我的问题:closeBarItemPressed:没有被调用,为什么以及如何解决它?

2 个答案:

答案 0 :(得分:1)

我也有这个问题。看起来在覆盖视图的底部忽略了触摸。尝试将按钮移动一点点,它会起作用。 (在你的情况下,如果你将工具栏框架更改为在屏幕顶部,我打赌你的方法将被调用,至少这是发生在我身上的事情)。不知道为什么会发生这种情况。

答案 1 :(得分:0)

基本上我通过使用修改后的iPad设置重新编译Zbar解决了我的问题。现在它运作正常。