Skip to content

Commit

Permalink
Merge pull request #2 from thiagoperes/master
Browse files Browse the repository at this point in the history
fix(delegate): Fixed a bug in which optional methods in delegate not implemented caused a crash

This commit fixes a crash that occurred when the hud image delegate method was not implemented by the delegate.
This commit also adds a podspec file and the related tag.
  • Loading branch information
michaelochs committed Dec 2, 2013
2 parents ae445da + 809e36b commit 620cee6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
13 changes: 13 additions & 0 deletions BCScanner.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = "BCScanner"
s.version = "0.0.1"
s.summary = "A barcode and qr code scanner that wraps the iOS7 scanning capabilities in a UIViewController"
s.homepage = "https://github.com/michaelochs/BCScanner"
s.license = { :type => 'Apache License, Version 2.0', :file => 'LICENSE' }
s.author = 'Michael Ochs'
s.platform = :ios, '7.0'
s.source = { :git => "https://github.com/michaelochs/BCScanner.git", :commit => "ae445da822b3058fe57f8c262ef8596326f31929" }
s.source_files = 'BCScanner', 'BCScanner/**/*.{h,m}'
s.framework = 'AVFoundation'
s.requires_arc = true
end
17 changes: 10 additions & 7 deletions BCScanner/BCScannerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ - (void)viewDidLoad

self.previewView.session = self.session;

UIImage *hudImage = [self.delegate scannerHUDImage:self];
if (hudImage) {
UIImageView *hudImageView = [[UIImageView alloc] initWithImage:hudImage];
hudImageView.contentMode = UIViewContentModeScaleToFill;
[self.previewView addSubview:hudImageView];
_hudImageView = hudImageView;
}
if ([self.delegate respondsToSelector:@selector(scannerHUDImage:)])
{
UIImage *hudImage = [self.delegate scannerHUDImage:self];
if (hudImage) {
UIImageView *hudImageView = [[UIImageView alloc] initWithImage:hudImage];
hudImageView.contentMode = UIViewContentModeScaleToFill;
[self.previewView addSubview:hudImageView];
_hudImageView = hudImageView;
}
}

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(focusAndExpose:)];
[self.previewView addGestureRecognizer:tapRecognizer];
Expand Down

0 comments on commit 620cee6

Please sign in to comment.