• 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
[iPhone] UITableViewCell Height with UIWebView content
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iPhone] UITableViewCell Height with UIWebView content


  • Subject: [iPhone] UITableViewCell Height with UIWebView content
  • From: Sandro Noël <email@hidden>
  • Date: Tue, 10 Aug 2010 15:04:12 -0400

Greetings.

I've been trying to set the table view cell's height for a custom tableviewCell containing a UIWebView
to display attributed content but i cant's get the height properly.

I am using a UITable View with sections, the first section shows a list of child objects
and the second section displays the current node's text.

Here is the explanation of my workout. yes it's a workout.

1: define a custom TableCellViewCell in interface builder, containing a UIWebView.
2: the UITableView is given a HTML String before being pushed on the Navigation view.
3: in the cellForRowAtIndexPath the cell is given the HTML String
4: i've also implemented the heightForRowAtIndexPath method. which calls a function that calculated the height of the cell using the text as source.

- (CGFloat) heightOfCellForString:(NSString *)string inTableView:(UITableView*)tblView andFont:(UIFont *)font{

	CGFloat minimumCellHeight = 44.0f;
	CGRect tableViewFrame = [tblView frame];
	CGSize textSize = { tableViewFrame.size.width, 200000.00f };
	CGSize size = [string sizeWithFont:font constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap];
	// if there is more than one line add a little padding..
	if (size.height > 21)
		size.height += 25;

	CGFloat result = MAX(size.height, minimumCellHeight);

	return result;
}

This function works great for ordinary cells, but falls verry verry short when it comes
to resizing the cell containing the UIWebView,

is there a effective way to tell how high the tableviewCell should be to accommodate the UITableCellView
at the heightForRowAtIndexPath stage?

since it is so tedious, Now i'm thinking this is a design flaw on my part,
trying to resize a TableCellView with posibily big content.

any advice?

Best regards.
Sandro Noel.


_______________________________________________

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

  • Follow-Ups:
    • Re: [iPhone] UITableViewCell Height with UIWebView content
      • From: glenn andreas <email@hidden>
  • Prev by Date: Re: Custom zones...
  • Next by Date: Re: Custom zones...
  • Previous by thread: Re: Math.h functions with CGFloat
  • Next by thread: Re: [iPhone] UITableViewCell Height with UIWebView content
  • Index(es):
    • Date
    • Thread