UIWebView text length
Is there any way to know the length of text being placed into a UIWebView? I ha开发者_开发知识库ve the need to be able to break between multiple UIWebViews, and in order to do this, after all of the HTML formatting is on the screen, I need to know if it fits into the frame. Or, maybe know if seeing the bottom requires scrolling. Open to suggestions!
Does the following answer give you what you need if you put a well known HTML element at the end and check what offset that is at?
How to determine UIWebView height based on content, within a variable height UITableView?
this is a bit hack-ish, but could you grab the content string of the html (by executing javascript on the webview) and take that information and compute the size given the font. From there, you could determine if that required size fits in your view or if scrolling would be required.
CGSize webViewSize = [yourString sizeWithFont:yourFont
constrainedToSize:maximumWebViewSize];
update: here's a link to the documentation for the method I describe above: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSString_UIKit_Additions/Reference/Reference.html
精彩评论