本人也在学习中,前面的文章基本是基础的不能再基础的,菜鸟得不能再菜鸟啦。
现在的这篇也是菜鸟级别的,基本不用写啥代码,不过会让你瞬间觉得你的程序高大上了,依然是几行的代码,不过你的App的功能会瞬间强大起来。。。。
这些代码可以让你瞬间拥有了强大的填表,标注,搜索,链接响应。。。等等曾经让人觉得复杂无比的功能。
先再附上这个产品的相关介绍页面:
产品页面--最近刚刚发布了新版本2.0
http://www.foxitsdk.com/products/mobile-pdf-sdk/
下载申请
https://www.foxitsoftware.com/products/sdk/register.php?product=MobilePDFSDK
注意:最好用公司邮箱申请哦,如果用163之类的申请,可能会收不到邮件哦!
好了,本文正式开工了。
关于UI Extensions Component
官网的介绍如下:
"The UI Extensions Component builds on the View Control, providing a customizable user interface with built-in tools for text selection, markup annotations, night mode, bookmark navigation and full-text searching. The UI Extensions Component is provided as a compiled component for rapid integration, and for complete flexibility source code is also provided which allows developers to customize the default user interface and control precisely the functionality of the default Tools."
说明:
UIExtensions 导入工程
导入libFoxitRDKUIExtensions.a
选中工程右键选择Add Files to "AmyTest" ,选择SDK包中的libFoxitRDKUIExtensions.a , Add加入
当然,这个产品还是初级阶段,期待后面的版本吧,UI Extensions的接口不够灵活,启用/禁用链接,等等一些功能的Enable/Disable。。。需要去修改UI extension的相关代码,或者把不需要的注释掉才可以。
现在才2.0,相信不久的将来,这些细节都将得到完善。。。。期待吧~~~
把UIExtensions的资源以及头文件导入
头文件只需要“UIExtensionsManager.h”,右键Add Files to "AmyTest" 选择ibs/uiextensions_src/uiextensions目录下的“UIExtensionsManager.h”.
导入资源,最简单的办法我把lib/uiextension_src/uiextension的目录拷贝到AmyTest目录下。
接着导入资源到工程,选中工程,右键Add Files to "AmyTest" 选择uiextension目录下的“Resources"目录。
加入之后工程长这样
更名ViewController.m 为ViewController.mm
敲代码
很简单,只需要初始化UIExtension就好啦,为了方便,我就继续加入到了”ViewController.mm”
首先在文件的开始部分导入"UIExtensionsManager.h"
#import "UIExtensionsManager.h"
接着UIExtensions初始化代码加入到之前显示的代码之后。
UIExtensionsManager* extensionsManager;
extensionsManager = [[UIExtensionsManager alloc] initWithPDFViewControl:myTestViewCtrl];
myTestViewCtrl.extensionsManager = extensionsManager;
加入这些代码之后,你的APP就高大上了不少,填表,链接响应的功能就自然有了,如下图,超链接会被用黄色高亮起来。点击就会进行相应的跳转了。
表单也可以进行填写啦。
share下整个代码文件吧:
#import "ViewController.h"
#import <FoxitRDK/FSPDFObjC.h>
#import <FoxitRDK/FSPDFViewControl.h>
#import "UIExtensionsManager.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString* sn = @"*****";
NSString* unlock = @"*****";
enum FS_ERRORCODE eRet = [FSLibrary init:sn key:unlock];
if (e_errSuccess != eRet) {
return;
}
//load doc
NSString* docPath= [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"pdf"];
FSPDFDoc* doc = [FSPDFDoc createFromFilePath:docPath];
if (e_errSuccess!=[doc load:nil]) {
return;
}
//init PDFViewerCtrl
FSPDFViewCtrl* myTestViewCtrl;
myTestViewCtrl = [[FSPDFViewCtrl alloc] initWithFrame:[self.view bounds]];
[myTestViewCtrl gotoPage:3 animated:true];
[myTestViewCtrl setDoc:doc];
[self.view addSubview:myTestViewCtrl];
UIExtensionsManager* extensionsManager;
extensionsManager = [[UIExtensionsManager alloc] initWithPDFViewControl:myTestViewCtrl];
myTestViewCtrl.extensionsManager = extensionsManager;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
接着我还想有标注,想做个Outline面板,想添加标注,要怎么做啊?
同样的简单,用户手册里面都有,傻瓜式的教学哦
请看:
http://www.foxitsdk.com/sdk-docs/http://www.foxitsdk.com/docs/mobile-pdf-sdk/developer_guide_ios.pdf
http://www.foxitsdk.com/docs/mobile-pdf-sdk/api_reference_ios/html/index.html
2.5.6章节会告诉你的。
前两天刚刚发布的版本,集成了大量的标注工具,并支持了填表,哈,下面的截图会告诉你支持了啥
欢迎技术交流,可以私信我哈~~