Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Convert the handler functions for the torch, flipCamera, and shutter …
Browse files Browse the repository at this point in the history
…buttons to IBAction (#511)

* Converted the handler functions for the torch, flipCamera, and shutter buttons to IBAction in order to expose them to custom/alternative overlay xibs.

* Added flipCameraButtonPressed and torchButtonPressed to CDVbcsViewController interface.

* Resize the UIView from the alternate xib so that it fits the screen.
  • Loading branch information
renatoc8 authored and macdonst committed Aug 8, 2017
1 parent 5f9461e commit f0a8664
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/ios/CDVBarcodeScanner.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ - (UIView*)buildOverlayView;
- (UIImage*)buildReticleImage;
- (void)shutterButtonPressed;
- (IBAction)cancelButtonPressed:(id)sender;
- (IBAction)flipCameraButtonPressed:(id)sender;
- (IBAction)torchButtonPressed:(id)sender;

@end

Expand Down Expand Up @@ -938,7 +940,7 @@ - (void)startCapturing {
}

//--------------------------------------------------------------------------
- (void)shutterButtonPressed {
- (IBAction)shutterButtonPressed {
self.shutterPressed = YES;
}

Expand All @@ -947,12 +949,12 @@ - (IBAction)cancelButtonPressed:(id)sender {
[self.processor performSelector:@selector(barcodeScanCancelled) withObject:nil afterDelay:0];
}

- (void)flipCameraButtonPressed:(id)sender
- (IBAction)flipCameraButtonPressed:(id)sender
{
[self.processor performSelector:@selector(flipCamera) withObject:nil afterDelay:0];
}

- (void)torchButtonPressed:(id)sender
- (IBAction)torchButtonPressed:(id)sender
{
[self.processor performSelector:@selector(toggleTorch) withObject:nil afterDelay:0];
}
Expand All @@ -967,7 +969,16 @@ - (UIView *)buildOverlayViewFromXib
NSLog(@"%@", @"An error occurred loading the overlay xib. It appears that the overlayView outlet is not set.");
return nil;
}


self.overlayView.autoresizesSubviews = YES;
self.overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.overlayView.opaque = NO;

CGRect bounds = self.view.bounds;
bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);

[self.overlayView setFrame:bounds];

return self.overlayView;
}

Expand Down

0 comments on commit f0a8664

Please sign in to comment.