Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-05-2011, 04:50 AM   #1 (permalink)
Registered Member
 
franium's Avatar
 
Join Date: Nov 2010
Posts: 68
franium is on a distinguished road
Default Problem displaying a custom uitableviewcell content

Hi,
I've a custom UITableViewCell with a UITextView in it. The cell grows dinamically with the uitableview as user enters text.
When I display the table, I have to calculate the height of the custom cell depending on the content text entered by the user, so in the
Code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
I use:
Code:
 
CGSize textSize = [myString sizeWithFont:[UIFont systemFontOfSize:17.0f]  constrainedToSize:CGSizeMake(320, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
return textSize.height;
The returned height seems correct, but the not visible text is truncated.
franium is offline   Reply With Quote
Old 06-05-2011, 04:53 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

you need to change also the height of your UITextView
yourTextView.frame = CGRectMake(x,y,w,h);
__________________
dany_dev is offline   Reply With Quote
Old 06-05-2011, 05:05 AM   #3 (permalink)
Registered Member
 
franium's Avatar
 
Join Date: Nov 2010
Posts: 68
franium is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
you need to change also the height of your UITextView
yourTextView.frame = CGRectMake(x,y,w,h);
I'm trying with
Code:
myTextView.frame = myCellWithTextView.bounds;
The result is better, but the problem isn't completely resolved. I'll continue on this path, thanks.
franium is offline   Reply With Quote
Old 06-05-2011, 05:09 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

yes, you should use contentsize to know how height is your textview content..

Code:
myTextView.frame = CGRectMake(myTextView.frame.origin.x, myTextView.frame.origin.y, myTextView.frame.size.width, myTextView.contentSize.height)
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
height, heightforrowatindexpath, uitableview cell, uitextview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
5 members and 318 guests
Dnnake, iOS.Lover, jenniead38, pbart, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:18 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0