Reputation: 8947
I have an Ipad application in which i am trying to do some barcode reading processes.when i am pressing a button in the home page i am presenting the barcode reading viewcontrollers view like this`
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];
and when i am pressing the scan button added to the reader view i need to add another view.for that i am doing -(IBAction)getpressed:(id)sender{[self.view addSubview:newview] }
.but it is not added to the view.can anybody help me to achieve this?
`
Upvotes: 1
Views: 562
Reputation: 2310
you need to overlay to your zbar view and add that button overlay view:
//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
Upvotes: 1