├── .gitignore ├── DemoQRCode ├── DemoQRCode.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── DemoQRCode │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── Example1Controller.h ├── Example1Controller.m ├── Example2Controller.h ├── Example2Controller.m ├── Example3Controller.h └── Example3Controller.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EDFCEDAC1BBA8034004E6B53 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFCEDAB1BBA8034004E6B53 /* main.m */; }; 11 | EDFCEDAF1BBA8034004E6B53 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFCEDAE1BBA8034004E6B53 /* AppDelegate.m */; }; 12 | EDFCEDB21BBA8034004E6B53 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFCEDB11BBA8034004E6B53 /* ViewController.m */; }; 13 | EDFCEDB71BBA8034004E6B53 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDFCEDB61BBA8034004E6B53 /* Assets.xcassets */; }; 14 | EDFCEDBA1BBA8034004E6B53 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDFCEDB81BBA8034004E6B53 /* LaunchScreen.storyboard */; }; 15 | EDFCEDC31BBA9309004E6B53 /* Example1Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFCEDC21BBA9309004E6B53 /* Example1Controller.m */; settings = {ASSET_TAGS = (); }; }; 16 | EDFCEDC61BBA9319004E6B53 /* Example2Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFCEDC51BBA9319004E6B53 /* Example2Controller.m */; settings = {ASSET_TAGS = (); }; }; 17 | EDFCEDC91BBA9323004E6B53 /* Example3Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFCEDC81BBA9323004E6B53 /* Example3Controller.m */; settings = {ASSET_TAGS = (); }; }; 18 | EDFCEDCB1BBA93EE004E6B53 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDFCEDCA1BBA93EE004E6B53 /* AVFoundation.framework */; }; 19 | EDFCEDCD1BBA9400004E6B53 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDFCEDCC1BBA9400004E6B53 /* CoreImage.framework */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | EDFCEDA71BBA8034004E6B53 /* DemoQRCode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DemoQRCode.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | EDFCEDAB1BBA8034004E6B53 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 25 | EDFCEDAD1BBA8034004E6B53 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 26 | EDFCEDAE1BBA8034004E6B53 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 27 | EDFCEDB01BBA8034004E6B53 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 28 | EDFCEDB11BBA8034004E6B53 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 29 | EDFCEDB61BBA8034004E6B53 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | EDFCEDB91BBA8034004E6B53 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | EDFCEDBB1BBA8034004E6B53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | EDFCEDC11BBA9308004E6B53 /* Example1Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Example1Controller.h; sourceTree = ""; }; 33 | EDFCEDC21BBA9309004E6B53 /* Example1Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Example1Controller.m; sourceTree = ""; }; 34 | EDFCEDC41BBA9319004E6B53 /* Example2Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Example2Controller.h; sourceTree = ""; }; 35 | EDFCEDC51BBA9319004E6B53 /* Example2Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Example2Controller.m; sourceTree = ""; }; 36 | EDFCEDC71BBA9323004E6B53 /* Example3Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Example3Controller.h; sourceTree = ""; }; 37 | EDFCEDC81BBA9323004E6B53 /* Example3Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Example3Controller.m; sourceTree = ""; }; 38 | EDFCEDCA1BBA93EE004E6B53 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 39 | EDFCEDCC1BBA9400004E6B53 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; }; 40 | /* End PBXFileReference section */ 41 | 42 | /* Begin PBXFrameworksBuildPhase section */ 43 | EDFCEDA41BBA8034004E6B53 /* Frameworks */ = { 44 | isa = PBXFrameworksBuildPhase; 45 | buildActionMask = 2147483647; 46 | files = ( 47 | EDFCEDCD1BBA9400004E6B53 /* CoreImage.framework in Frameworks */, 48 | EDFCEDCB1BBA93EE004E6B53 /* AVFoundation.framework in Frameworks */, 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXFrameworksBuildPhase section */ 53 | 54 | /* Begin PBXGroup section */ 55 | EDFCED9E1BBA8034004E6B53 = { 56 | isa = PBXGroup; 57 | children = ( 58 | EDFCEDC71BBA9323004E6B53 /* Example3Controller.h */, 59 | EDFCEDC81BBA9323004E6B53 /* Example3Controller.m */, 60 | EDFCEDC41BBA9319004E6B53 /* Example2Controller.h */, 61 | EDFCEDC51BBA9319004E6B53 /* Example2Controller.m */, 62 | EDFCEDC11BBA9308004E6B53 /* Example1Controller.h */, 63 | EDFCEDC21BBA9309004E6B53 /* Example1Controller.m */, 64 | EDFCEDA91BBA8034004E6B53 /* DemoQRCode */, 65 | EDFCEDA81BBA8034004E6B53 /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | EDFCEDA81BBA8034004E6B53 /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | EDFCEDA71BBA8034004E6B53 /* DemoQRCode.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | EDFCEDA91BBA8034004E6B53 /* DemoQRCode */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | EDFCEDAD1BBA8034004E6B53 /* AppDelegate.h */, 81 | EDFCEDAE1BBA8034004E6B53 /* AppDelegate.m */, 82 | EDFCEDB01BBA8034004E6B53 /* ViewController.h */, 83 | EDFCEDB11BBA8034004E6B53 /* ViewController.m */, 84 | EDFCEDB61BBA8034004E6B53 /* Assets.xcassets */, 85 | EDFCEDB81BBA8034004E6B53 /* LaunchScreen.storyboard */, 86 | EDFCEDBB1BBA8034004E6B53 /* Info.plist */, 87 | EDFCEDAA1BBA8034004E6B53 /* Supporting Files */, 88 | EDFCEDCC1BBA9400004E6B53 /* CoreImage.framework */, 89 | EDFCEDCA1BBA93EE004E6B53 /* AVFoundation.framework */, 90 | ); 91 | path = DemoQRCode; 92 | sourceTree = ""; 93 | }; 94 | EDFCEDAA1BBA8034004E6B53 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | EDFCEDAB1BBA8034004E6B53 /* main.m */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | /* End PBXGroup section */ 103 | 104 | /* Begin PBXNativeTarget section */ 105 | EDFCEDA61BBA8034004E6B53 /* DemoQRCode */ = { 106 | isa = PBXNativeTarget; 107 | buildConfigurationList = EDFCEDBE1BBA8034004E6B53 /* Build configuration list for PBXNativeTarget "DemoQRCode" */; 108 | buildPhases = ( 109 | EDFCEDA31BBA8034004E6B53 /* Sources */, 110 | EDFCEDA41BBA8034004E6B53 /* Frameworks */, 111 | EDFCEDA51BBA8034004E6B53 /* Resources */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = DemoQRCode; 118 | productName = DemoQRCode; 119 | productReference = EDFCEDA71BBA8034004E6B53 /* DemoQRCode.app */; 120 | productType = "com.apple.product-type.application"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | EDFCED9F1BBA8034004E6B53 /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0700; 129 | ORGANIZATIONNAME = LJC; 130 | TargetAttributes = { 131 | EDFCEDA61BBA8034004E6B53 = { 132 | CreatedOnToolsVersion = 7.0.1; 133 | }; 134 | }; 135 | }; 136 | buildConfigurationList = EDFCEDA21BBA8034004E6B53 /* Build configuration list for PBXProject "DemoQRCode" */; 137 | compatibilityVersion = "Xcode 3.2"; 138 | developmentRegion = English; 139 | hasScannedForEncodings = 0; 140 | knownRegions = ( 141 | en, 142 | Base, 143 | ); 144 | mainGroup = EDFCED9E1BBA8034004E6B53; 145 | productRefGroup = EDFCEDA81BBA8034004E6B53 /* Products */; 146 | projectDirPath = ""; 147 | projectRoot = ""; 148 | targets = ( 149 | EDFCEDA61BBA8034004E6B53 /* DemoQRCode */, 150 | ); 151 | }; 152 | /* End PBXProject section */ 153 | 154 | /* Begin PBXResourcesBuildPhase section */ 155 | EDFCEDA51BBA8034004E6B53 /* Resources */ = { 156 | isa = PBXResourcesBuildPhase; 157 | buildActionMask = 2147483647; 158 | files = ( 159 | EDFCEDBA1BBA8034004E6B53 /* LaunchScreen.storyboard in Resources */, 160 | EDFCEDB71BBA8034004E6B53 /* Assets.xcassets in Resources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXResourcesBuildPhase section */ 165 | 166 | /* Begin PBXSourcesBuildPhase section */ 167 | EDFCEDA31BBA8034004E6B53 /* Sources */ = { 168 | isa = PBXSourcesBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | EDFCEDC91BBA9323004E6B53 /* Example3Controller.m in Sources */, 172 | EDFCEDC31BBA9309004E6B53 /* Example1Controller.m in Sources */, 173 | EDFCEDC61BBA9319004E6B53 /* Example2Controller.m in Sources */, 174 | EDFCEDB21BBA8034004E6B53 /* ViewController.m in Sources */, 175 | EDFCEDAF1BBA8034004E6B53 /* AppDelegate.m in Sources */, 176 | EDFCEDAC1BBA8034004E6B53 /* main.m in Sources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXSourcesBuildPhase section */ 181 | 182 | /* Begin PBXVariantGroup section */ 183 | EDFCEDB81BBA8034004E6B53 /* LaunchScreen.storyboard */ = { 184 | isa = PBXVariantGroup; 185 | children = ( 186 | EDFCEDB91BBA8034004E6B53 /* Base */, 187 | ); 188 | name = LaunchScreen.storyboard; 189 | sourceTree = ""; 190 | }; 191 | /* End PBXVariantGroup section */ 192 | 193 | /* Begin XCBuildConfiguration section */ 194 | EDFCEDBC1BBA8034004E6B53 /* Debug */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 199 | CLANG_CXX_LIBRARY = "libc++"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_CONSTANT_CONVERSION = YES; 204 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 205 | CLANG_WARN_EMPTY_BODY = YES; 206 | CLANG_WARN_ENUM_CONVERSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_UNREACHABLE_CODE = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | DEBUG_INFORMATION_FORMAT = dwarf; 214 | ENABLE_STRICT_OBJC_MSGSEND = YES; 215 | ENABLE_TESTABILITY = YES; 216 | GCC_C_LANGUAGE_STANDARD = gnu99; 217 | GCC_DYNAMIC_NO_PIC = NO; 218 | GCC_NO_COMMON_BLOCKS = YES; 219 | GCC_OPTIMIZATION_LEVEL = 0; 220 | GCC_PREPROCESSOR_DEFINITIONS = ( 221 | "DEBUG=1", 222 | "$(inherited)", 223 | ); 224 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 225 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 226 | GCC_WARN_UNDECLARED_SELECTOR = YES; 227 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 228 | GCC_WARN_UNUSED_FUNCTION = YES; 229 | GCC_WARN_UNUSED_VARIABLE = YES; 230 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 231 | MTL_ENABLE_DEBUG_INFO = YES; 232 | ONLY_ACTIVE_ARCH = YES; 233 | SDKROOT = iphoneos; 234 | TARGETED_DEVICE_FAMILY = "1,2"; 235 | }; 236 | name = Debug; 237 | }; 238 | EDFCEDBD1BBA8034004E6B53 /* Release */ = { 239 | isa = XCBuildConfiguration; 240 | buildSettings = { 241 | ALWAYS_SEARCH_USER_PATHS = NO; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 253 | CLANG_WARN_UNREACHABLE_CODE = YES; 254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 255 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 256 | COPY_PHASE_STRIP = NO; 257 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 258 | ENABLE_NS_ASSERTIONS = NO; 259 | ENABLE_STRICT_OBJC_MSGSEND = YES; 260 | GCC_C_LANGUAGE_STANDARD = gnu99; 261 | GCC_NO_COMMON_BLOCKS = YES; 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 269 | MTL_ENABLE_DEBUG_INFO = NO; 270 | SDKROOT = iphoneos; 271 | TARGETED_DEVICE_FAMILY = "1,2"; 272 | VALIDATE_PRODUCT = YES; 273 | }; 274 | name = Release; 275 | }; 276 | EDFCEDBF1BBA8034004E6B53 /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 280 | INFOPLIST_FILE = DemoQRCode/Info.plist; 281 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 282 | PRODUCT_BUNDLE_IDENTIFIER = com.adad184.DemoQRCode; 283 | PRODUCT_NAME = "$(TARGET_NAME)"; 284 | }; 285 | name = Debug; 286 | }; 287 | EDFCEDC01BBA8034004E6B53 /* Release */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | INFOPLIST_FILE = DemoQRCode/Info.plist; 292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 293 | PRODUCT_BUNDLE_IDENTIFIER = com.adad184.DemoQRCode; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | }; 296 | name = Release; 297 | }; 298 | /* End XCBuildConfiguration section */ 299 | 300 | /* Begin XCConfigurationList section */ 301 | EDFCEDA21BBA8034004E6B53 /* Build configuration list for PBXProject "DemoQRCode" */ = { 302 | isa = XCConfigurationList; 303 | buildConfigurations = ( 304 | EDFCEDBC1BBA8034004E6B53 /* Debug */, 305 | EDFCEDBD1BBA8034004E6B53 /* Release */, 306 | ); 307 | defaultConfigurationIsVisible = 0; 308 | defaultConfigurationName = Release; 309 | }; 310 | EDFCEDBE1BBA8034004E6B53 /* Build configuration list for PBXNativeTarget "DemoQRCode" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | EDFCEDBF1BBA8034004E6B53 /* Debug */, 314 | EDFCEDC01BBA8034004E6B53 /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | }; 318 | /* End XCConfigurationList section */ 319 | }; 320 | rootObject = EDFCED9F1BBA8034004E6B53 /* Project object */; 321 | } 322 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "Example1Controller.h" 11 | #import "Example2Controller.h" 12 | #import "Example3Controller.h" 13 | 14 | @interface AppDelegate () 15 | 16 | @end 17 | 18 | @implementation AppDelegate 19 | 20 | 21 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 22 | // Override point for customization after application launch. 23 | 24 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 25 | 26 | UITabBarController *tab = [UITabBarController new]; 27 | UIViewController *vc1 = [Example1Controller new]; 28 | UIViewController *vc2 = [Example2Controller new]; 29 | UIViewController *vc3 = [Example3Controller new]; 30 | 31 | vc1.tabBarItem.title = @"扫描"; 32 | vc2.tabBarItem.title = @"读取"; 33 | vc3.tabBarItem.title = @"生成"; 34 | 35 | tab.view.backgroundColor = [UIColor whiteColor]; 36 | 37 | tab.viewControllers = @[vc1,vc2,vc3]; 38 | 39 | self.window.rootViewController = tab; 40 | 41 | [self.window makeKeyAndVisible]; 42 | 43 | 44 | 45 | 46 | return YES; 47 | } 48 | 49 | - (void)applicationWillResignActive:(UIApplication *)application { 50 | // 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. 51 | // 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. 52 | } 53 | 54 | - (void)applicationDidEnterBackground:(UIApplication *)application { 55 | // 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. 56 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 57 | } 58 | 59 | - (void)applicationWillEnterForeground:(UIApplication *)application { 60 | // 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. 61 | } 62 | 63 | - (void)applicationDidBecomeActive:(UIApplication *)application { 64 | // 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. 65 | } 66 | 67 | - (void)applicationWillTerminate:(UIApplication *)application { 68 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /DemoQRCode/DemoQRCode/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DemoQRCode/Example1Controller.h: -------------------------------------------------------------------------------- 1 | // 2 | // Example1Controller.h 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Example1Controller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DemoQRCode/Example1Controller.m: -------------------------------------------------------------------------------- 1 | // 2 | // Example1Controller.m 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "Example1Controller.h" 10 | #import 11 | 12 | @interface Example1Controller() 13 | < 14 | AVCaptureMetadataOutputObjectsDelegate, 15 | UIAlertViewDelegate 16 | > 17 | 18 | @property (nonatomic, strong) UIView *scanRectView; 19 | 20 | @property (strong, nonatomic) AVCaptureDevice *device; 21 | @property (strong, nonatomic) AVCaptureDeviceInput *input; 22 | @property (strong, nonatomic) AVCaptureMetadataOutput *output; 23 | @property (strong, nonatomic) AVCaptureSession *session; 24 | @property (strong, nonatomic) AVCaptureVideoPreviewLayer *preview; 25 | 26 | @end 27 | 28 | @implementation Example1Controller 29 | 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | // Do any additional setup after loading the view. 34 | 35 | CGSize windowSize = [UIScreen mainScreen].bounds.size; 36 | 37 | CGSize scanSize = CGSizeMake(windowSize.width*3/4, windowSize.width*3/4); 38 | CGRect scanRect = CGRectMake((windowSize.width-scanSize.width)/2, (windowSize.height-scanSize.height)/2, scanSize.width, scanSize.height); 39 | 40 | scanRect = CGRectMake(scanRect.origin.y/windowSize.height, scanRect.origin.x/windowSize.width, scanRect.size.height/windowSize.height,scanRect.size.width/windowSize.width); 41 | 42 | self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 43 | 44 | self.input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil]; 45 | 46 | self.output = [[AVCaptureMetadataOutput alloc]init]; 47 | [self.output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; 48 | 49 | self.session = [[AVCaptureSession alloc]init]; 50 | [self.session setSessionPreset:([UIScreen mainScreen].bounds.size.height<500)?AVCaptureSessionPreset640x480:AVCaptureSessionPresetHigh]; 51 | [self.session addInput:self.input]; 52 | [self.session addOutput:self.output]; 53 | self.output.metadataObjectTypes=@[AVMetadataObjectTypeQRCode]; 54 | self.output.rectOfInterest = scanRect; 55 | 56 | self.preview = [AVCaptureVideoPreviewLayer layerWithSession:self.session]; 57 | self.preview.videoGravity = AVLayerVideoGravityResizeAspectFill; 58 | self.preview.frame = [UIScreen mainScreen].bounds; 59 | [self.view.layer insertSublayer:self.preview atIndex:0]; 60 | 61 | self.scanRectView = [UIView new]; 62 | [self.view addSubview:self.scanRectView]; 63 | self.scanRectView.frame = CGRectMake(0, 0, scanSize.width, scanSize.height); 64 | self.scanRectView.center = CGPointMake(CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds)); 65 | self.scanRectView.layer.borderColor = [UIColor redColor].CGColor; 66 | self.scanRectView.layer.borderWidth = 1; 67 | 68 | 69 | //开始捕获 70 | [self.session startRunning]; 71 | 72 | } 73 | 74 | 75 | - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection 76 | { 77 | if ( (metadataObjects.count==0) ) 78 | { 79 | return; 80 | } 81 | 82 | if (metadataObjects.count>0) { 83 | 84 | [self.session stopRunning]; 85 | 86 | AVMetadataMachineReadableCodeObject *metadataObject = metadataObjects.firstObject; 87 | //输出扫描字符串 88 | 89 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:metadataObject.stringValue message:@"" delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil]; 90 | 91 | [alert show]; 92 | } 93 | } 94 | 95 | - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex 96 | { 97 | [self.session startRunning]; 98 | } 99 | 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /DemoQRCode/Example2Controller.h: -------------------------------------------------------------------------------- 1 | // 2 | // Example2Controller.h 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Example2Controller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DemoQRCode/Example2Controller.m: -------------------------------------------------------------------------------- 1 | // 2 | // Example2Controller.m 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "Example2Controller.h" 10 | 11 | @interface Example2Controller() 12 | < 13 | UINavigationControllerDelegate, 14 | UIImagePickerControllerDelegate 15 | > 16 | 17 | @property (nonatomic, strong) UIButton *btnRead; 18 | 19 | @end 20 | 21 | @implementation Example2Controller 22 | 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | self.btnRead = [UIButton buttonWithType:UIButtonTypeContactAdd]; 28 | [self.view addSubview:self.btnRead]; 29 | self.btnRead.center = CGPointMake(CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds)); 30 | [self.btnRead addTarget:self action:@selector(actionRead) forControlEvents:UIControlEventTouchUpInside]; 31 | 32 | 33 | } 34 | 35 | - (void)actionRead 36 | { 37 | UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init]; 38 | 39 | photoPicker.delegate = self; 40 | photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 41 | photoPicker.view.backgroundColor = [UIColor whiteColor]; 42 | [self presentViewController:photoPicker animated:YES completion:NULL]; 43 | } 44 | 45 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 46 | { 47 | [self dismissViewControllerAnimated:YES completion:^{ 48 | 49 | }]; 50 | 51 | UIImage * srcImage = [info objectForKey:UIImagePickerControllerOriginalImage]; 52 | 53 | CIContext *context = [CIContext contextWithOptions:nil]; 54 | CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:context options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}]; 55 | CIImage *image = [CIImage imageWithCGImage:srcImage.CGImage]; 56 | NSArray *features = [detector featuresInImage:image]; 57 | CIQRCodeFeature *feature = [features firstObject]; 58 | 59 | NSString *result = feature.messageString; 60 | 61 | if ( result ) 62 | { 63 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:result message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles: nil]; 64 | 65 | [alert show]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /DemoQRCode/Example3Controller.h: -------------------------------------------------------------------------------- 1 | // 2 | // Example3Controller.h 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Example3Controller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DemoQRCode/Example3Controller.m: -------------------------------------------------------------------------------- 1 | // 2 | // Example3Controller.m 3 | // DemoQRCode 4 | // 5 | // Created by Ralph Li on 9/29/15. 6 | // Copyright © 2015 LJC. All rights reserved. 7 | // 8 | 9 | #import "Example3Controller.h" 10 | 11 | @interface Example3Controller() 12 | 13 | @property (nonatomic, strong) UITextField *tfCode; 14 | @property (nonatomic, strong) UIButton *btnGenerate; 15 | @property (nonatomic, strong) UIImageView *imageView; 16 | 17 | @end 18 | 19 | @implementation Example3Controller 20 | 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | CGSize windowSize = [UIScreen mainScreen].bounds.size; 26 | 27 | self.tfCode = [[UITextField alloc] initWithFrame:CGRectMake(10, 30, windowSize.width-100, 40)]; 28 | [self.view addSubview:self.tfCode]; 29 | self.tfCode.borderStyle = UITextBorderStyleRoundedRect; 30 | 31 | self.btnGenerate = [[UIButton alloc] initWithFrame:CGRectMake(windowSize.width-100, 30, 90, 40)]; 32 | [self.view addSubview:self.btnGenerate]; 33 | [self.btnGenerate addTarget:self action:@selector(actionGenerate) forControlEvents:UIControlEventTouchUpInside]; 34 | self.btnGenerate.backgroundColor = [UIColor lightGrayColor]; 35 | [self.btnGenerate setTitle:@"生成" forState:UIControlStateNormal]; 36 | [self.btnGenerate setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 37 | 38 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)]; 39 | [self.view addSubview:self.imageView]; 40 | self.imageView.center = CGPointMake(windowSize.width/2, windowSize.height/2); 41 | 42 | self.tfCode.text = @"http://adad184.com"; 43 | 44 | // [self actionGenerate]; 45 | } 46 | 47 | - (void)actionGenerate 48 | { 49 | NSString *text = self.tfCode.text; 50 | 51 | NSData *stringData = [text dataUsingEncoding: NSUTF8StringEncoding]; 52 | 53 | //生成 54 | CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; 55 | [qrFilter setValue:stringData forKey:@"inputMessage"]; 56 | [qrFilter setValue:@"M" forKey:@"inputCorrectionLevel"]; 57 | 58 | UIColor *onColor = [UIColor redColor]; 59 | UIColor *offColor = [UIColor blueColor]; 60 | 61 | //上色 62 | CIFilter *colorFilter = [CIFilter filterWithName:@"CIFalseColor" 63 | keysAndValues: 64 | @"inputImage",qrFilter.outputImage, 65 | @"inputColor0",[CIColor colorWithCGColor:onColor.CGColor], 66 | @"inputColor1",[CIColor colorWithCGColor:offColor.CGColor], 67 | nil]; 68 | 69 | CIImage *qrImage = colorFilter.outputImage; 70 | 71 | //绘制 72 | CGSize size = CGSizeMake(300, 300); 73 | CGImageRef cgImage = [[CIContext contextWithOptions:nil] createCGImage:qrImage fromRect:qrImage.extent]; 74 | UIGraphicsBeginImageContext(size); 75 | CGContextRef context = UIGraphicsGetCurrentContext(); 76 | CGContextSetInterpolationQuality(context, kCGInterpolationNone); 77 | CGContextScaleCTM(context, 1.0, -1.0); 78 | CGContextDrawImage(context, CGContextGetClipBoundingBox(context), cgImage); 79 | UIImage *codeImage = UIGraphicsGetImageFromCurrentImageContext(); 80 | UIGraphicsEndImageContext(); 81 | 82 | CGImageRelease(cgImage); 83 | 84 | self.imageView.image = codeImage; 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 ralph li 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DemoQRCode 2 | Demo shows how to deal with QRCode without 3rd party library 3 | --------------------------------------------------------------------------------