-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 368fcf4
Showing
26 changed files
with
1,978 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TFBarcodeScanner.xcodeproj/project.xcworkspace/xcuserdata | ||
TFBarcodeScanner.xcodeproj/xcuserdata/tony.xcuserdatad | ||
TFBarcodeScanner.xcodeproj/project.xcworkspace/xcshareddata/TFBarcodeScannerDemo.xccheckout | ||
TFBarcodeScanner.xcodeproj/project.xcworkspace/xcshareddata/TFBarcodeScanner.xccheckout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// AppDelegate.h | ||
// TFBarcodeScannerDemo | ||
// | ||
// Created by Tony Mann on 5/23/14. | ||
// Copyright (c) 2014 TheFind. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// AppDelegate.m | ||
// TFBarcodeScannerDemo | ||
// | ||
// Created by Tony Mann on 5/23/14. | ||
// Copyright (c) 2014 TheFind. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
|
||
@implementation AppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
// Override point for customization after application launch. | ||
return YES; | ||
} | ||
|
||
- (void)applicationWillResignActive:(UIApplication *)application | ||
{ | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
} | ||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application | ||
{ | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application | ||
{ | ||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application | ||
{ | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application | ||
{ | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
@end |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Demo/Images.xcassets/LaunchImage.launchimage/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"subtype" : "retina4", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.thefind.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UIMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// Prefix header | ||
// | ||
// The contents of this file are implicitly included at the beginning of every source file. | ||
// | ||
|
||
#import <Availability.h> | ||
|
||
#ifndef __IPHONE_5_0 | ||
#warning "This project uses features only available in iOS SDK 5.0 and later." | ||
#endif | ||
|
||
#ifdef __OBJC__ | ||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// ViewController.h | ||
// TFBarcodeScannerDemo | ||
// | ||
// Created by Tony Mann on 5/23/14. | ||
// Copyright (c) 2014 TheFind. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "TFBarcodeScanner.h" | ||
|
||
@interface ViewController : TFBarcodeScannerViewController | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// ViewController.m | ||
// TFBarcodeScannerDemo | ||
// | ||
// Created by Tony Mann on 5/23/14. | ||
// Copyright (c) 2014 TheFind. All rights reserved. | ||
// | ||
|
||
#import "ViewController.h" | ||
|
||
@interface ViewController () | ||
|
||
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; | ||
@property (weak, nonatomic) IBOutlet UIView *overlayView; | ||
@property (weak, nonatomic) IBOutlet UIView *resultsView; | ||
@property (weak, nonatomic) IBOutlet UILabel *barcodeTypeLabel; | ||
@property (weak, nonatomic) IBOutlet UILabel *barcodeStringLabel; | ||
@property (weak, nonatomic) IBOutlet UILabel *noCameraLabel; | ||
|
||
@end | ||
|
||
|
||
@implementation ViewController | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
self.barcodeTypes = TFBarcodeTypeEAN8 | TFBarcodeTypeEAN13 | TFBarcodeTypeUPCA | TFBarcodeTypeUPCE | TFBarcodeTypeQRCODE; | ||
self.resultsView.alpha = 0.0f; | ||
self.overlayView.alpha = 0.0f; | ||
self.noCameraLabel.hidden = self.hasCamera; | ||
} | ||
|
||
- (UIStatusBarStyle)preferredStatusBarStyle | ||
{ | ||
return UIStatusBarStyleLightContent; | ||
} | ||
|
||
#pragma mark - TFBarcodeScannerViewController | ||
|
||
- (void)barcodePreviewWillShowWithDuration:(CGFloat)duration | ||
{ | ||
[UIView animateWithDuration:duration animations:^{ | ||
self.overlayView.alpha = 1.0f; | ||
} completion:^(BOOL finished) { | ||
[self.activityIndicator stopAnimating]; | ||
}]; | ||
} | ||
|
||
- (void)barcodePreviewWillHideWithDuration:(CGFloat)duration | ||
{ | ||
|
||
} | ||
|
||
- (void)barcodeWasScanned:(NSSet *)barcodes | ||
{ | ||
[self stop]; | ||
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); | ||
|
||
TFBarcode* barcode = [barcodes anyObject]; | ||
self.resultsView.hidden = NO; | ||
self.barcodeTypeLabel.text = [self stringFromBarcodeType:barcode.type]; | ||
self.barcodeStringLabel.text = barcode.string; | ||
|
||
[UIView animateWithDuration:0.2 animations:^{ | ||
self.resultsView.alpha = 1.0f; | ||
}]; | ||
} | ||
|
||
- (IBAction)scanAgainButtonWasTapped | ||
{ | ||
[self start]; | ||
|
||
[UIView animateWithDuration:0.5 animations:^{ | ||
self.resultsView.alpha = 0.0f; | ||
}]; | ||
} | ||
|
||
#pragma mark - Private | ||
|
||
- (NSString *)stringFromBarcodeType:(TFBarcodeType)barcodeType | ||
{ | ||
static NSDictionary *typeMap; | ||
|
||
if (!typeMap) { | ||
typeMap = @{ | ||
@(TFBarcodeTypeEAN8): @"EAN8", | ||
@(TFBarcodeTypeEAN13): @"EAN13", | ||
@(TFBarcodeTypeUPCA): @"UPCA", | ||
@(TFBarcodeTypeUPCE): @"UPCE", | ||
@(TFBarcodeTypeQRCODE): @"QRCODE", | ||
@(TFBarcodeTypeCODE128): @"CODE128", | ||
@(TFBarcodeTypeCODE39): @"CODE39", | ||
@(TFBarcodeTypeCODE39Mod43): @"CODE39Mod43", | ||
@(TFBarcodeTypeCODE93): @"CODE93", | ||
@(TFBarcodeTypePDF417): @"PDF417", | ||
@(TFBarcodeTypeAztec): @"Aztec" | ||
}; | ||
} | ||
|
||
return typeMap[@(barcodeType)]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// main.m | ||
// TFBarcodeScannerDemo | ||
// | ||
// Created by Tony Mann on 5/23/14. | ||
// Copyright (c) 2014 TheFind. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import "AppDelegate.h" | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
@autoreleasepool { | ||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 thefind | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
TFBarcodeScanner | ||
================ | ||
|
||
Scan barcodes in iOS7 with elegance and ease | ||
|
||
 | ||
|
||
iOS7 provides barcode scanning as part of the AV Framework, but it takes some work to | ||
figure it all out and then set it up to be efficient and robust. TFBarcodeScanner makes | ||
it super easy: create a view controller subclass of `TFBarcodeScannerViewController`, | ||
override `barcodeWasScanned`, and you are scanning barcodes! | ||
|
||
## Installation | ||
|
||
We recommend using CocoaPods to install TFBarcodeScanner. Add to your Podfile: | ||
|
||
pod 'TFBarcodeScanner' | ||
|
||
To install manually, add TFBarcodeScanner to your project as a subproject, and | ||
then add the TFBarcodeScanner static library in your project's Build Phases. | ||
|
||
## Usage | ||
|
||
1. Create a view controller that is subclassed from `TFBarcodeScannerViewController`. | ||
Make sure that your subviews have a transparent region so the preview is visible. | ||
1. In your `viewDidLoad` method, optionally set the `barcodeTypes` bit flag to whatever | ||
barcode types you want to scan. | ||
1. Override the `barcodeWasScanned` method. This returns a set of barcodes that were | ||
recognized. You normally will call `stop` once a suitable barcode is recognized. | ||
1. If you have UI elements that you want to overlay on top of the scanning preview, | ||
override `barcodePreviewWillShowWithDuration` and show the elements in this method. You | ||
will also want to override `barcodePreviewWillHideWithDuration` to hide these same | ||
elements. | ||
|
||
See the Demo for sample code. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "TFBarcodeScanner" | ||
s.version = "1.0.0" | ||
s.summary = "Scan barcodes in iOS7 with elegance and ease" | ||
s.description = <<-DESC | ||
iOS7 provides barcode scanning as part of the AV Framework, but it takes | ||
some work to figure it all out and then set it up to be efficient and robust. TFBarcodeScanner | ||
makes it super easy: create a view controller subclass of `TFBarcodeScannerViewController`, | ||
override `barcodeWasScanned`, and you are scanning barcodes! | ||
DESC | ||
s.homepage = "https://github.com/thefind/TFBarcodeScanner" | ||
s.screenshots = "https://raw.githubusercontent.com/thefind/TFBarcodeScanner/master/Screenshots/screenshot.png" | ||
s.license = "MIT" | ||
s.author = { "phatmann" => "[email protected]" } | ||
s.social_media_url = "http://twitter.com/thephatmann" | ||
s.platform = :ios, "7.0" | ||
s.source = { :git => "https://github.com/thefind/TFBarcodeScanner.git", :tag => "1.0.0" } | ||
s.source_files = "TFBarcodeScanner" | ||
s.requires_arc = true | ||
end |
Oops, something went wrong.