UIWebView分页/行中断 [英] UIWebView paging / line cut off

查看:46
本文介绍了UIWebView分页/行中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对网页进行页面设置,因此禁用滚动功能,然后第二个页面是向下滚动页面高度的同一页面。

I am trying to page a webpage, so disable scrolling, then the second page is the same webpage scrolled down the page height.

我遇到的问题是第一页的底部通常有1/2行文本,然后第二页的是该行的底部一半。

The problem I have is that the bottom of the first page often has 1/2 a line of text, then the second page has the bottom half of the line.

有没有一种方法可以确保整行落在页面之一上?类似于Stanza等?

Is there a way to ensure the entire line falls on one of the pages? Similar to Stanza etc?

谢谢

推荐答案

您必须要分页将网页分成与UIWebView高度匹配的块。如果您无法手动执行此操作,或者想要支持其他设备和方向,则必须使用Javascript。

You have to paginate the web page into blocks that match the height of the UIWebView. If you cannot do that manually, or you want to support different devices and orientations, you will have to do it in Javascript.

我不知道有什么快速方法可以用Javascript中的渲染大小来度量和破坏文本。本文可能会有所帮助,但是您需要的是一种方法来询问给定空间填充了多少文本,而不是给定文本填充了多少空间。 trimToPx方法仅适用于单行,对于大量文本来说会很慢。

I do not know of any fast way to measure and break text by rendered size in Javascript. This article may help, but what you need is a way to ask how much text fills a given space, not how much space a given text fills. The trimToPx method here only works for a single line and would be slow for a large body of text.

> http://blog.mastykarz.nl/measuring-the-length-of-a-string -in-pixels-using-javascript /

有些文本测量示例这里

iPhone OS没有提供高级例程来通过测量来破坏文本,特别是样式文字,尽管我还没有检查4.0 SDK。您可以使用CoreGraphics渲染来测量文本,但这相当困难并且不支持html。

The iPhone OS does not provide high level routines to break text by measurement, especially styled text, although I have not checked the 4.0 SDK. You can use CoreGraphics rendering to measure text but that is fairly difficult and would not support html.

这篇关于UIWebView分页/行中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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