Skip to content

Instantly share code, notes, and snippets.

@keith-kurak
Created December 1, 2016 15:15
Show Gist options
  • Save keith-kurak/303f5a4056aeccc2d927f833ccad7c0e to your computer and use it in GitHub Desktop.
Save keith-kurak/303f5a4056aeccc2d927f833ccad7c0e to your computer and use it in GitHub Desktop.
Test Objective C snippet
//start scanning when the Scan button is pushed down (touch down)
- (IBAction)startScanning:(id)sender {
if(![self.session isRunning])
{
[self.barcodeScanAreaView.layer addSublayer:_prevLayer];
[_session startRunning];
[self.barcodeScanAreaView bringSubviewToFront:_highlightView]; //isn't necessary at this point because the line gets removed before anyone sees it. Could be useful if there was a delay before shutting down the view and recording the scan
}
}
//stop scanning when the button is pushed up (inside button) (touch up inside)
- (IBAction)stopScanning:(id)sender {
if([self.session isRunning])
{
[_session stopRunning]; //this makes the camera stop streaming to the screen.
[self.prevLayer removeFromSuperlayer]; //this makes the view containing the camera image go blank
}
}
//stop scanning when the button is pushed up (outside button) (touch up outside)
- (IBAction)stopScanning_Outside:(id)sender {
if([self.session isRunning])
{
[_session stopRunning];
[self.prevLayer removeFromSuperlayer];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment