Skip to content

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelochs committed Dec 23, 2014
2 parents 1a7ab7e + 8340b3d commit c99ec58
Show file tree
Hide file tree
Showing 8 changed files with 1,305 additions and 612 deletions.
5 changes: 2 additions & 3 deletions BCScanner.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Pod::Spec.new do |s|
s.name = "BCScanner"
s.version = "0.1.0"
s.version = "0.1.1"
s.summary = "A barcode and qr code scanner that wraps the `AVFoundation` 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, @_mochs'
s.platform = :ios, '8.0'
s.ios.deployment_target = '7.0'
s.platform = :ios, '7.0'
s.requires_arc = true
s.framework = 'AVFoundation', 'UIKit'
s.source = { :git => "https://github.com/michaelochs/BCScanner.git", :tag => s.version.to_s }
Expand Down
34 changes: 4 additions & 30 deletions BCScanner/BCScannerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,6 @@ @interface BCScannerViewController () <AVCaptureMetadataOutputObjectsDelegate>
@end


static inline CGRect HUDRect(CGRect bounds, UIEdgeInsets padding, CGFloat aspectRatio)
{
CGRect frame = UIEdgeInsetsInsetRect(bounds, padding);

CGFloat frameAspectRatio = CGRectGetWidth(frame) / CGRectGetHeight(frame);
CGRect hudRect = frame;

if (aspectRatio > frameAspectRatio) {
hudRect.size.height = CGRectGetHeight(frame) / aspectRatio;
hudRect.origin.y += (CGRectGetHeight(frame) - CGRectGetHeight(hudRect)) * .5f;
} else {
hudRect.size.width = CGRectGetHeight(frame) * aspectRatio;
hudRect.origin.x += (CGRectGetWidth(frame) - CGRectGetWidth(hudRect)) * .5f;
}

return CGRectIntegral(hudRect);
}


@implementation BCScannerViewController

@dynamic previewView;
Expand Down Expand Up @@ -153,6 +134,7 @@ + (NSString *)metadataObjectTypeFromScannerCode:(NSString *)code
BCScannerAztecCode: AVMetadataObjectTypeAztecCode,
};

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
NSMutableDictionary *optionalCodeTypes = [NSMutableDictionary new];
if (&AVMetadataObjectTypeInterleaved2of5Code) {
optionalCodeTypes[BCScannerI25Code] = AVMetadataObjectTypeInterleaved2of5Code;
Expand All @@ -168,6 +150,7 @@ + (NSString *)metadataObjectTypeFromScannerCode:(NSString *)code
[optionalCodeTypes addEntriesFromDictionary:objectTypes];
objectTypes = [optionalCodeTypes copy];
}
#endif
});
return objectTypes[code];
}
Expand Down Expand Up @@ -221,7 +204,7 @@ - (void)updateMetaData
{
BOOL isVisible = self.isViewLoaded && self.view.window;
if (self.isTorchButtonEnabled) {
UIBarButtonItem *torchToggle = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringWithDefaultValue(@"bcscanner_torch", nil, [NSBundle mainBundle], @"Torch", @"The title of the torch mode button") style:UIBarButtonItemStyleBordered target:self action:@selector(toggleTorch:)];
UIBarButtonItem *torchToggle = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringWithDefaultValue(@"bcscanner_torch", nil, [NSBundle mainBundle], @"Torch", @"The title of the torch mode button") style:UIBarButtonItemStylePlain target:self action:@selector(toggleTorch:)];
[self.navigationItem setRightBarButtonItem:torchToggle animated:isVisible];
} else {
[self.navigationItem setRightBarButtonItem:nil animated:isVisible];
Expand Down Expand Up @@ -401,17 +384,8 @@ - (void)updateRectOfInterest
self.metadataOutput.rectOfInterest = CGRectMake(0.0, 0.0, 1.0, 1.0);
return;
}
CGRect rectOfInterest = (CGRect){
.origin = {
.x = CGRectGetMinX(self.scannerArea) / CGRectGetWidth(self.view.bounds),
.y = CGRectGetMinY(self.scannerArea) / CGRectGetHeight(self.view.bounds)
},
.size = {
.width = CGRectGetWidth(self.scannerArea) / CGRectGetWidth(self.view.bounds),
.height = CGRectGetHeight(self.scannerArea) / CGRectGetHeight(self.view.bounds)
}
};

CGRect rectOfInterest = [self.previewView.previewLayer metadataOutputRectOfInterestForRect:self.scannerArea];
self.metadataOutput.rectOfInterest = rectOfInterest;
}

Expand Down
2 changes: 2 additions & 0 deletions BCScanner/Private/BCVideoPreviewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
@property (nonatomic, strong, readwrite) AVCaptureSession *session;
@property (nonatomic, assign, readwrite) AVCaptureVideoOrientation videoOrientation;

@property (nonatomic, strong, readonly) AVCaptureVideoPreviewLayer *previewLayer;

@property (nonatomic) AVCaptureTorchMode torchMode;
@property (nonatomic, assign, readonly, getter = isTorchModeAvailable) BOOL torchModeAvailable;

Expand Down
2 changes: 0 additions & 2 deletions BCScanner/Private/BCVideoPreviewView.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

@interface BCVideoPreviewView ()

@property (nonatomic, strong, readonly) AVCaptureVideoPreviewLayer *previewLayer;

@end


Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#Changelog
# Changelog

The versioning in this project is based on [Semantic Versioning](http://semver.org).

## v0.1.1
- Fix issues with the scanner area property
- Reenables iOS7 support
- Removes warnings

## v0.1.0
- First official release, containing support for the following code types:
- aztec
Expand Down
Loading

0 comments on commit c99ec58

Please sign in to comment.