使用不在IOS 5中工作的UIWebview导航Pdf [英] Navigating a Pdf using UIWebview not working in IOS 5

查看:99
本文介绍了使用不在IOS 5中工作的UIWebview导航Pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到了Xcode 4,我发现一款运行良好超过一年的应用程序现在无法在Ios 5下工作。该应用程序在UIWebview中导航Pdf并使用以下代码移至Pdf中的任何页面。

I have recently upgraded to Xcode 4 and I've found that an app which has worked perfectly well for over a year is now not working under Ios 5. The app navigates a Pdf in UIWebview and uses the following code to move to any page within the Pdf.

[self.pdfNavigateController.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.scrollTo(0, %d);", self.pdfNavigateController.scrollPosition]];

当我使用4.2版本的任何模拟器时,代码完美无缺,但在Ios 5模拟器下代码不会工作。

When I use any simulator from 4.2 down the code works perfectly but under the Ios 5 simulator the code wont work.

通过论坛来看,似乎存在一些课程发生变化的问题。在Ios 5下有什么变化,我该怎么做才能解决这个问题?

Looking through the forum there seems to be a number of issues where classes have changed. What has changed under Ios 5 and what can I do to rectify the problem?

推荐答案

您可以使用UIWebView的Scrollview作为Javascript导航不再支持:下面是我的代码工作正常。

You can use UIWebView's Scrollview for navigation as Javascript is no more supported: Below is a my code worked fine for me.

    [aWebView.scrollView setContentOffset:CGPointMake(x, y)];

contentOffset接受CGPoint作为参数。这里x和y是表示scrollPosition的整数值。如果你想获得webView的当前x和y坐标,下面是你可以使用的代码:

The contentOffset accepts a CGPoint as argument. Here x and y are integer values representing the scrollPosition. If you want to get current x and y co-ordinates for webView, below is the code which you can use:

NSInteger x = aWebview.scrollView.contentOffSet.x;
NSInteger y = aWebview.scrollView.contentOffset.y;

注意: ScrollView是在IOS 5中引入的,不会在早期使用IOS版本。 Javascript函数适用于早期版本。因此,您可以检查设备版本并相应地实现代码。

Note: ScrollView is introduced in IOS 5 and will not work on earlier IOS versions. Javascript function are available for earlier versions. So you can check for device version and implement code accordingly.

这篇关于使用不在IOS 5中工作的UIWebview导航Pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆