Skip to content

Commit 15671e2

Browse files
update ios
1 parent 11de68a commit 15671e2

File tree

281 files changed

+13435
-5556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+13435
-5556
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ This repository contains multiple samples that demonstrates how to use the [Dyna
2020

2121
| Sample Name | Description | Programming Language(s) |
2222
| ----------- | ----------- | ----------------------- |
23-
| `HelloWorld` | This is an Android sample that illustrates the simplest way to recognize barcodes from video streaming with Dynamsoft Barcode Reader SDK and Dynamsoft Camera Enhancer SDK. | Java(Android)/Objective-C/Swift |
24-
| `GeneralSettings` | This is an Android sample that illustrates how to make general settings when using Dynamsoft Barcode Reader. | Java(Android)/Objective-C/Swift |
25-
| `SpeedFirstSettings` | This is an Android sample that shows how to configure Dynamsoft Barcode Reader to read barcodes as fast as possible. The downside is that read-rate and accuracy might be affected. | Java(Android)/Objective-C/Swift |
26-
| `ReadRateFirstSettings` | This is an Android sample that shows how to configure Dynamsoft Barcode Reader to read as many barcodes as possible at one time. The downside is that speed and accuracy might be affected. It is recommended to apply these configurations when decoding multiple barcodes from a single image. | Java(Android)/Objective-C/Swift |
27-
| `AccuracyFirstSettings` | This is an Android sample that shows how to configure Dynamsoft Barcode Reader to read barcodes as accurately as possible. The downside is that speed and read-rate might be affected. It is recommended to apply these configurations when misreading is unbearable. | Java(Android)/Objective-C/Swift |
28-
| `ReadADriversLicense` | This is an Android sample that shows how to create a mobile app that focus on decoding the drivers' license barcodes and displaying the parsed information. | Java(Android)/Swift |
23+
| `HelloWorld` | This is a sample that illustrates the simplest way to recognize barcodes from video streaming with Dynamsoft Barcode Reader SDK and Dynamsoft Camera Enhancer SDK. | Java(Android)/Objective-C/Swift |
24+
| `GeneralSettings` | This is a sample that illustrates how to make general settings when using Dynamsoft Barcode Reader. | Java(Android)/Objective-C/Swift |
25+
| `PerformanceSettings` | This is a sample that shows parameter configuration guide on improving the speed, read-rate and accuracy of barcode reading. | Java(Android)/Objective-C/Swift |
26+
| `ReadADriversLicense` | This is a sample that shows how to create a mobile app that focus on decoding the drivers' license barcodes and displaying the parsed information. | Java(Android)/Swift |
2927

3028
### How to build (For iOS Editions)
3129

ios/Objective-C/GeneralSettingsObjC/GeneralSettingsObjC.xcodeproj/project.pbxproj

Lines changed: 448 additions & 119 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
//
2+
// AppDelegate.h
3+
// GeneralSettings
4+
//
5+
// Created by dynamsoft on 2021/11/25.
6+
//
17

28
#import <UIKit/UIKit.h>
39

410
@interface AppDelegate : UIResponder <UIApplicationDelegate>
511

6-
@property (strong, nonatomic) UIWindow *window;
7-
12+
@property (strong, nonatomic) UIWindow * window;
813

914
@end
1015

Lines changed: 85 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,109 @@
1+
//
2+
// AppDelegate.m
3+
// GeneralSettings
4+
//
5+
// Created by dynamsoft on 2021/11/25.
6+
//
17

28
#import "AppDelegate.h"
9+
#import "BaseNavigationController.h"
10+
#import "MainViewController.h"
311

4-
@interface AppDelegate ()
12+
@interface AppDelegate ()<DCELicenseVerificationListener>
513

614
@end
715

816
@implementation AppDelegate
917

10-
1118
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1219
// Override point for customization after application launch.
20+
21+
22+
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
23+
self.window.backgroundColor = [UIColor whiteColor];
24+
25+
[self.window makeKeyAndVisible];
26+
27+
MainViewController *rootVC = [[MainViewController alloc] init];
28+
BaseNavigationController *naviVC = [[BaseNavigationController alloc] initWithRootViewController:rootVC];
29+
self.window.rootViewController = naviVC;
30+
31+
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-200, 0)
32+
forBarMetrics:UIBarMetricsDefault];
33+
34+
// You should set the DCE License in AppDelegate
35+
[DynamsoftCameraEnhancer initLicense:@"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" verificationDelegate:self];
36+
1337
return YES;
1438
}
1539

16-
- (void)applicationWillResignActive:(UIApplication *)application {
17-
// 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.
18-
// 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.
40+
- (void)applicationDidEnterBackground:(UIApplication *)application
41+
{
42+
[[NSNotificationCenter defaultCenter] postNotificationName:appDidEnterToBackground_Notication object:nil];
43+
}
44+
45+
- (void)applicationWillEnterForeground:(UIApplication *)application
46+
{
47+
[[NSNotificationCenter defaultCenter] postNotificationName:appWillEnterToForeground_Notication object:nil];
1948
}
2049

21-
- (void)applicationDidEnterBackground:(UIApplication *)application {
22-
// 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.
23-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
50+
//MARK: DCELicenseVerificationListener
51+
- (void)DCELicenseVerificationCallback:(bool)isSuccess error:(NSError *)error
52+
{
53+
[self verificationCallback:error];
2454
}
2555

26-
- (void)applicationWillEnterForeground:(UIApplication *)application {
27-
// 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.
56+
- (void)verificationCallback:(NSError *)error{
57+
58+
NSString* msg = @"";
59+
if(error != nil)
60+
{
61+
msg = error.userInfo[NSUnderlyingErrorKey];
62+
if(msg == nil)
63+
{
64+
msg = [error localizedDescription];
65+
}
66+
[self showResult:@"Server license verify failed"
67+
msg:msg
68+
acTitle:@"OK"
69+
completion:^{
70+
}];
71+
}
72+
}
73+
74+
- (void)showResult:(NSString *)title msg:(NSString *)msg acTitle:(NSString *)acTitle completion:(void (^)(void))completion {
75+
76+
dispatch_async(dispatch_get_main_queue(), ^{
77+
78+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
79+
[alert addAction:[UIAlertAction actionWithTitle:acTitle style:UIAlertActionStyleDefault
80+
handler:^(UIAlertAction * action) {
81+
completion();
82+
}]];
83+
UIViewController *topViewController = [self topViewController];
84+
[topViewController presentViewController:alert animated:YES completion:nil];
85+
86+
});
2887
}
2988

30-
- (void)applicationDidBecomeActive:(UIApplication *)application {
31-
// 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.
89+
- (UIViewController *)topViewController {
90+
UIViewController *resultVC;
91+
resultVC = [self getTopViewController:[[UIApplication sharedApplication].keyWindow rootViewController]];
92+
while (resultVC.presentedViewController) {
93+
resultVC = [self getTopViewController:resultVC.presentedViewController];
94+
}
95+
return resultVC;
3296
}
3397

34-
- (void)applicationWillTerminate:(UIApplication *)application {
35-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
98+
- (UIViewController *)getTopViewController:(UIViewController *)vc {
99+
if ([vc isKindOfClass:[UINavigationController class]]) {
100+
return [self getTopViewController:[(UINavigationController *)vc topViewController]];
101+
} else if ([vc isKindOfClass:[UITabBarController class]]) {
102+
return [self getTopViewController:[(UITabBarController *)vc selectedViewController]];
103+
} else {
104+
return vc;
105+
}
106+
return nil;
36107
}
37108

38109
@end

ios/Swift/Performance/AccuracyFirstSettingsSwift/AccuracyFirstSettingsSwift/Assets.xcassets/Contents.json renamed to ios/Objective-C/GeneralSettingsObjC/GeneralSettingsObjC/Assets.xcassets/AccentColor.colorset/Contents.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
27
"info" : {
38
"author" : "xcode",
49
"version" : 1
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<scenes>
1212
<!--View Controller-->
1313
<scene sceneID="EHf-IW-A2E">
1414
<objects>
1515
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
16-
<layoutGuides>
17-
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
18-
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
19-
</layoutGuides>
2016
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
21-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
17+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
2218
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23-
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
19+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
20+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
2421
</view>
2522
</viewController>
2623
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
2724
</objects>
2825
<point key="canvasLocation" x="53" y="375"/>
2926
</scene>
3027
</scenes>
28+
<resources>
29+
<systemColor name="systemBackgroundColor">
30+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
31+
</systemColor>
32+
</resources>
3133
</document>
Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="0VB-0F-HMf">
3-
<device id="retina4_7" orientation="portrait" appearance="light"/>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
79
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
810
</dependencies>
911
<scenes>
10-
<!--GeneralSettings-->
12+
<!--Main View Controller-->
1113
<scene sceneID="tne-QT-ifu">
1214
<objects>
13-
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
14-
<layoutGuides>
15-
<viewControllerLayoutGuide type="top" id="z5w-iF-94j"/>
16-
<viewControllerLayoutGuide type="bottom" id="2Ug-bu-mgh"/>
17-
</layoutGuides>
15+
<viewController id="BYZ-38-t0r" customClass="MainViewController" sceneMemberID="viewController">
1816
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
19-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
17+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
2018
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
21-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
19+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
20+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
2221
</view>
23-
<navigationItem key="navigationItem" title="GeneralSettings" id="9o4-Uj-dep"/>
2422
</viewController>
2523
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2624
</objects>
27-
<point key="canvasLocation" x="4178" y="285"/>
28-
</scene>
29-
<!--Navigation Controller-->
30-
<scene sceneID="ymq-6J-8W8">
31-
<objects>
32-
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="0VB-0F-HMf" sceneMemberID="viewController">
33-
<toolbarItems/>
34-
<navigationBar key="navigationBar" contentMode="scaleToFill" barStyle="black" id="VhQ-ji-Fno">
35-
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
36-
<autoresizingMask key="autoresizingMask"/>
37-
<textAttributes key="titleTextAttributes">
38-
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
39-
</textAttributes>
40-
</navigationBar>
41-
<nil name="viewControllers"/>
42-
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="2Tw-LM-KYV">
43-
<autoresizingMask key="autoresizingMask"/>
44-
</toolbar>
45-
<connections>
46-
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="esu-YO-4lB"/>
47-
</connections>
48-
</navigationController>
49-
<placeholder placeholderIdentifier="IBFirstResponder" id="Gws-0i-zNx" userLabel="First Responder" sceneMemberID="firstResponder"/>
50-
</objects>
51-
<point key="canvasLocation" x="3068" y="285"/>
25+
<point key="canvasLocation" x="35" y="8"/>
5226
</scene>
5327
</scenes>
28+
<resources>
29+
<systemColor name="systemBackgroundColor">
30+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
31+
</systemColor>
32+
</resources>
5433
</document>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// BaseNavigationController.h
3+
// GeneralSettings
4+
//
5+
// Created by dynamsoft on 2021/11/18.
6+
//
7+
8+
#import <UIKit/UIKit.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface BaseNavigationController : UINavigationController
13+
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// BaseNavigationController.m
3+
// GeneralSettings
4+
//
5+
// Created by dynamsoft on 2021/11/18.
6+
//
7+
8+
#import "BaseNavigationController.h"
9+
10+
@interface BaseNavigationController ()
11+
12+
@end
13+
14+
@implementation BaseNavigationController
15+
16+
- (void)viewDidLoad
17+
{
18+
[super viewDidLoad];
19+
20+
21+
}
22+
23+
- (BOOL)prefersStatusBarHidden
24+
{
25+
return self.visibleViewController.prefersStatusBarHidden;
26+
}
27+
28+
- (UIStatusBarStyle)preferredStatusBarStyle
29+
{
30+
UIViewController* topVC = self.topViewController;
31+
return [topVC preferredStatusBarStyle];
32+
33+
}
34+
35+
36+
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// BaseViewController.h
3+
// GeneralSettings
4+
//
5+
// Created by dynamsoft on 2021/11/18.
6+
//
7+
8+
#import <UIKit/UIKit.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface BaseViewController : UIViewController
13+
14+
@end
15+
16+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)