Install SGQRCode via CocoaPods
masterTo integrate SGQRCode into your iOS project using CocoaPods, add the following line to your Podfile:
pod 'SGQRCode', '~> 4.1.0'repository·master·Indexed 23 days ago
https://github.com/kingsic/sgqrcodeAn iOS library for generating and scanning QR codes. It includes SGScanCode for scanning via camera or static images, SGGenerateQRCode for creating QR codes with optional logos, and utilities for managing camera/photo permissions (SGPermission) and flashlight control (SGTorch).
To integrate SGQRCode into your iOS project using CocoaPods, add the following line to your Podfile:
pod 'SGQRCode', '~> 4.1.0'SGQRCode requires access to the camera and photo library. You must add the following keys to your Info.plist file to provide usage descriptions to the user:
NSCameraUsageDescription: For camera access.NSPhotoLibraryUsageDescription: For photo library access.If you encounter the error [!] Unable to find a specification for SGQRCode during installation, run the following commands in your terminal to refresh your local pod specs:
pod repo remove masterpod setuppod repo remove master
pod setupSGGenerateQRCode to create QR code images. You can generate standard QR codes or QR codes that include a logo with a specific ratio.Implement these delegate methods to handle scanning results and environmental changes like brightness.
SGScanCodeDelegate Called when a QR code is successfully scanned.
SGScanCodeSampleBufferDelegate Called to provide brightness information, which can be used to manage the flashlight (SGTorch).
// SGScanCodeDelegate
- (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
<#code#>
}
// SGScanCodeSampleBufferDelegate
- (void)scanCode:(SGScanCode *)scanCode brightness:(CGFloat)brightness {
<#code#>
}readQRCode:completion: method on an SGScanCode instance to extract QR code data from a static image.To implement QR code scanning, use the SGScanCode class. You must set a preview view and implement the SGScanCodeDelegate and SGScanCodeSampleBufferDelegate protocols.
Note: Version 4.x uses a Delegate pattern, whereas version 3.5x used Blocks.
The following classes are the primary interfaces for the library:
SGScanCode: Handles QR code scanning.SGScanViewConfigure: Configuration for the scanning view.SGScanView: The scanning view component.SGPermission: Manages camera and photo library permissions.SGTorch: Manages the device flashlight.SGQRCodeLog: Provides debugging logs.