用Dynamsoft Camera SDK iOS版本快速创建一个拍摄文档应用 - Objective-C开发

如果您尚未在Xcode项目中安装Dynamsoft Camera SDK框架,请参考下面进行配置:

1. 如果您还没下载Dynamsoft Camera SDK iOS版30天免费试用,请在这里下载。

2. 创建一个新的Xcode项目。

2.1 找到General选项卡,在Embedded Binaries部分下,单击+按钮添加嵌入式框架。

2.2 选择 'Add Other...'。

2.3 找到并选择 DynamsoftCameraSDK.framework。

2.4 勾选 'Copy items if needed' 和 'Create groups' 这两个选项,然后点击 'Finish'。

3. 将所需的.tbd文件添加到项目中。

3.1 到Xcode项目的“General”选项卡,在“Linked Frameworks and Libraries”下,单击“+”按钮。

3.2 搜索libstdc ++.tbd文件,选择它并单击“Add”按钮。 然后该文件将被复制到您的项目中。

3.3 搜索libsqlite3.0.tbd,选择它并单击"Add"按钮。 然后该文件将被复制到您的项目中。

4. 找到"Other Linker Flags "并添加值“-ObjC”。

注意:对于iOS 10及更高版本,请转到项目的“Info”选项卡,在“Custom iOS Target Properties”下,单击+,输入“NSCameraUsageDescription”并按“enter”按钮,然后设置值 “Privacy - Camera Usage Description”。

5. 接下来,您可以添加代码以在项目中实现图像捕获功能,以Objective-C为例。

5.1 打开ViewController.m文件
您可以看到默认的ViewController.m,如下所示:

5.2 导入框架的头文件

#import <DynamsoftCameraSDK/DcsView.h>
#import <DynamsoftCameraSDK/DcsUIImageGalleryView.h>
#import <DynamsoftCameraSDK/DcsUIVideoView.h>

5.3. 修改ViewController

@interface ViewController () {
    DcsView *dcsView;
    UIButton *openVideoViewButton;
}
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
     
    dcsView = [[DcsView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    //Show VideoView when DcsView is loaded
    dcsView.currentView = DVE_VIDEOVIEW;
     
    ///video view settting//
    //Set the videoview capture mode to document mode
    dcsView.videoView.mode = DME_DOCUMENT;
     
    //Set the next view after the cancel or capture button is clicked.
    dcsView.videoView.nextViewAfterCancel = DVE_IMAGEGALLERYVIEW;
    dcsView.videoView.nextViewAfterCapture= DVE_EDITORVIEW;
     
    [self.view addSubview:dcsView];
     
    openVideoViewButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.center.x-100, self.view.center.y-20, 200, 40)];
    [openVideoViewButton setTitle:@"Back to Camera" forState:normal];
    [openVideoViewButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [openVideoViewButton addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside];
     
    [dcsView.imageGalleryView addSubview:openVideoViewButton];
     
}
 
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
- (void) onClick{
    dcsView.currentView = DVE_VIDEOVIEW;
}
 
 
@end

6. 连上iPhone(需要iPhone 5s或更高),看运行效果。

单击捕获按钮后,捕获的文档将显示在内置的文档编辑器视图中:

编辑完成后,您可以点击“OK”,在图库视图中查看到编辑好的文档:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值