[iPhone] UITableViewCell Height with UIWebView content
[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