Re: UIWebView height calculation
Re: UIWebView height calculation
- Subject: Re: UIWebView height calculation
- From: Alex Kac <email@hidden>
- Date: Mon, 7 Sep 2009 21:26:06 -0500
- (void) webViewDidFinishLoad:(UIWebView *)sender {
[self performSelector:@selector(calculateWebViewSize) withObject:nil
afterDelay:0.1];
}
- (void) calculateWebViewSize {
//size the notes view
float newHeight = [[notesWebView
stringByEvaluatingJavaScriptFromString
:@"document.documentElement.scrollHeight"] floatValue];
}
On Sep 7, 2009, at 9:16 PM, Dragos Ionel wrote:
Hi,
1. I am trying to find how much text fits in a UIWebView of a certain
size (let's say 320x400).
For this, I am using a UIWebViewDelegate in the following way:
- (void)webViewDidFinishLoad:(UIWebView *)webView{
//...
CGSize size = [webView sizeThatFits:CGSizeZero];
int h = size.height;
if(h<=maxHeight) {
//add another character to the string htmlContent
...
} else {
//reached the maximum height, do nothing
return;
}
[webView loadHTMLString:htmlContent baseURL:[NSURL
URLWithString:@""]];
}
Is it a good idea to call loadHTMLString from a delegate?
The delegate is supposed to run in a different thread than the main
one
2. Is there a simpler way to find how much content can fit in a
UIWebView?
Thanks a lot,
Dragos
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Alex Kac - President and Founder
Web Information Solutions, Inc.
"Forgiveness is not an occasional act: it is a permanent attitude."
-- Dr. Martin Luther King
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden