简体   繁体   English

PdfViewController.scroll位置不适用于IOS 5中的UIWebview

[英]PdfViewController.scroll Position not working with UIWebview in IOS 5

I have an app which scrolls through Pdf files using buttons and an index within a UIWebview. 我有一个应用程序,可以使用按钮和UIWebview中的索引在Pdf文件中滚动。 It uses the code PdfViewController.scrollPosition to move to specified position's within the Pdf file. 它使用代码PdfViewController.scrollPosition移动到Pdf文件中的指定位置。 The app has been working fine and was sent to iTunes months ago but recently I have upgraded to Xcode 4 and when I try to run my app using the Ios 5 simulator the positioning will not work. 该应用程序运行良好,已于几个月前发送到iTunes,但最近我已升级到Xcode 4,当我尝试使用Ios 5模拟器运行我的应用程序时,定位将不起作用。

What has changed in the new Ios 5 that prevents the above code from working? 新的Ios 5中发生了哪些更改,导致上述代码无法正常工作?

This was answered via another similar question I posted. 我发布的另一个类似问题回答了这个问题。 The reason that it now doesn't work, is that IOS 5 does not support Javascript (Thank you Apple). 现在它不起作用的原因是IOS 5不支持Javascript(谢谢Apple)。 You can use a different method to navigate through your Pdf by using webView.scrollView to move through your Pdf pages. 您可以使用webView.scrollView来浏览Pdf页面,而可以使用另一种方法来浏览Pdf。

I have answered a similar question. 我已经回答了类似的问题。 Below is the answer. 以下是答案。 Hope it solves your problem. 希望它能解决您的问题。 You can use UIWebView's Scrollview for navigation as Javascript is no more supported in IOS5: Below is a my code worked fine for me.PdfViewController is a webview 您可以使用UIWebView的Scrollview进行导航,因为IOS5中不再支持Javascript:以下是我的代码对我来说很好用.PdfViewController是一个webview

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

The contentOffset accepts a CGPoint as argument. contentOffset接受CGPoint作为参数。 Here x and y are integer values representing the scrollPosition. 这里的x和y是表示scrollPosition的整数值。 If you want to get current x and y co-ordinates for webView, below is the code which you can use: 如果要获取webView的当前x和y坐标,则可以使用以下代码:

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

Note: ScrollView is introduced in IOS 5 and will not work on earlier IOS versions. 注意:ScrollView是IOS 5中引入的,不适用于早期的IOS版本。 Javascript function are available for earlier versions. Javascript功能可用于早期版本。 So you can check for device version and implement code accordingly. 因此,您可以检查设备版本并相应地实施代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM