1

我有一个 Ipad 应用程序,我正在尝试执行一些条形码读取过程。当我按下主页中的按钮时,我正在呈现条形码读取 viewcontrollers 视图,如下所示`

    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;

    reader.supportedOrientationsMask = ZBarOrientationMaskAll;

    reader.sourceType=UIImagePickerControllerSourceTypeCamera;
    //reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;

    reader.cameraOverlayView=cameraOverlay;

    if( [UIImagePickerController isCameraDeviceAvailable:                         UIImagePickerControllerCameraDeviceFront ])
    {
           reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
    }
    ZBarImageScanner *scanner = reader.scanner;

    reader.wantsFullScreenLayout = YES;
    // TODO: (optional) additional reader configuration here

    // EXAMPLE: disable rarely used I2/5 to improve performance

    [scanner setSymbology: ZBAR_I25
                   config: ZBAR_CFG_ENABLE
                       to: 0];
     reader.showsZBarControls = NO; 
    // present and release the controller
   [self presentModalViewController:reader animated:YES];
    //[appdel.navigationController pushViewController:reader animated:YES];

    //[reader.view addSubview:collect];
    [reader.view addSubview:back];
      [back addTarget:self action:@selector(backpressed:) forControlEvents:UIControlEventTouchUpInside];
    [reader.view addSubview:scan];
    [scan addTarget:self action:@selector(getpressed:) forControlEvents:UIControlEventTouchUpInside];

    [reader release];

当我按下添加到阅读器视图的扫描按钮时,我需要添加另一个视图。我正在这样做。-(IBAction)getpressed:(id)sender{[self.view addSubview:newview] }但它没有添加到视图中。有人可以帮我实现这一点吗?`

4

1 回答 1

1

您需要覆盖到您的 zbar 视图并添加该按钮覆盖视图:

//set the frame according to your requirement 
aOverlay = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,480.0)]; 
aOverlay.backgroundColor = [UIColor clearColor];
UIButton *aBtnscan  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[aBtnscan setFrame:CGRectMake(115, 435, 80, 45)];

[aBtnscan addTarget:self action:@selector(getpressed:)forControlEvents:UIControlEventTouchUpInside];
[aOverlay addSubview:aBtnscan];
reader.cameraOverlayView = aOverlay; 
// You code
于 2012-07-02T09:19:24.770 回答