• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UIWebView height calculation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >UIWebView height calculation (From: Dragos Ionel <email@hidden>)

  • Prev by Date: UIWebView height calculation
  • Next by Date: Re: Menu Weirdness (can't set command + 3 or command + 4)
  • Previous by thread: UIWebView height calculation
  • Next by thread: NSImage with Core Foundation Console Application failed?
  • Index(es):
    • Date
    • Thread