ios 打开文档的选择续

来源:互联网 发布:华邦地产网络办公平台 编辑:程序博客网 时间:2024/05/20 11:24

前面一个blog讲了好几种文档已经相关,甚至不相关,有可能的库,类啊,比较杂乱,有专门做过这块的同学会懂得。。。。


基本来说我们经历过:uiwebview觉得so easy,and so good,然后觉得有个比较符合的viewer就是QLpreview,最后一个类型就是自己把基本的封装起来的方式,对于不同类型的文档,进行不同的处理,比如pdf,可选专业库,也可用默认,甚至第三方的库。对office文档,进行多种处理。多其它类型的采用通用方式。。


Adding Gesture Capability to UIWebView
 
http://www.codeproject.com/Articles/85944/Building-Simple-Reader-Application-for-iPhone-base#Adding
可以考虑快速书签 功能,左划 //通过对gesture的识别,进行处理

 http://www.techrepublic.com/blog/ios-app-builder/create-intricately-formatted-content-for-you-app-using-uiwebview/


uiwebview的更多功能,调整,单个打开后的一些功能是和脚本有关的,比如search功能:::::

Javascript framework

Using a Javascript framework is not necessary, but it could make coding easier. If you decide to use one, check out baseJS. It’s a lightweight framework written specifically for the iOS platform. There is no cross-platform nor cross-browser code, so your page will load much faster than other frameworks.

Disable scrolling

Add the following lines to your document load event handler:

document.ontouchmove = function(event) {event.preventDefault();};

This setups an event handler for ontouchmove and prevent its default behaviors.

Disable bounces

Disables the bouncing rubberband effect when the page is scrolled beyond its bounds.

// disable bouncesfor (id subview in webView_.subviews)if ([[subview class] isSubclassOfClass: [UIScrollView class]])((UIScrollView *)subview).bounces = NO;

Execute Javascript in UIWebView

Call stringByEvaluatingJavaScriptFromString with your script as the parameter. Here’s an example taken from the example project:

- (void)setPercent:(NSInteger)percent{NSString *javascript = [NSString stringWithFormat:@"ExampleApp.setPercent(%i)", percent];[webView_ stringByEvaluatingJavaScriptFromString:javascript];}

Call Objective-C from Javascript

Check out this post about how to properly call Objective-C from Javascript. Kyle Newsome had also posted an excellent tutorial demonstrating this technique.

Transparent UIWebView

Set the opaque and backgroundColor properties of UIWebView:

webView.opaque = NO;webView.backgroundColor = [UIColor clearColor];

And set the background-color property of the body element:

body {background-color: transparent;}

Disable selection

Add the following lines to your CSS style:

* {    -webkit-touch-callout: none;    // Disable selection/Copy of UIWebView    -webkit-user-select: none;}

Disable all user interactions

If you want to disable all user interactions, including selection, copy, paste and clicks, simply set the userInteractionEnabled property to NO.

uiwebview的属性 userinteractionenabled.

Source code may be downloaded here. If you find this tutorial helpful


原创粉丝点击