开发者

UIWebView paging / line cut off

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

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.

Is there a way to ensure the entire line falls on one开发者_StackOverflow中文版 of the pages? Similar to Stanza etc?

Thanks


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.

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/

There are some text measuring examples here as well.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜