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 04-30-2008, 10:19 AM   #1 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 7
Cander is an unknown quantity at this point
Default UITableViewCell height set at cell creation

I need to set the height of a cell after creation of the cell since I will not know until then how high it needs to be. My question is, when does tableView:heightForRowAtIndexPath: get called? Is it after tableView:cellForRowAtIndexPath: has returned so I can get the required height from my custom cell class? I am away from my Mac right now it the thought just occured to me to ask about this.
Cander is offline   Reply With Quote
Old 05-05-2008, 11:29 AM   #2 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 312
jonc is an unknown quantity at this point
Send a message via AIM to jonc
Default Re: UITableViewCell height set at cell creation

Do you need each cell to have a different height?
jonc is offline   Reply With Quote
Old 05-05-2008, 01:06 PM   #3 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 7
Cander is an unknown quantity at this point
Default Re: UITableViewCell height set at cell creation

Quote:
Originally Posted by jonc
Do you need each cell to have a different height?
Just the 2nd cell out of 3 needs to be dynamic in height. I haven't had much time the past few days to actually work on this, but I can't wrap my head around a solution except to get the needed height before the view loads, but was hoping for something quicker that I might have missed.
Cander is offline   Reply With Quote
Old 05-05-2008, 01:57 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 312
jonc is an unknown quantity at this point
Send a message via AIM to jonc
Default Re: UITableViewCell height set at cell creation

I just implemented custom cell height in something I was working on. I could only figure out how to set the hight when the view loads. I wasn't able to do it after the view loaded. There may be a way, but if there is I couldn't figure it out either.
jonc is offline   Reply With Quote
Old 05-05-2008, 03:01 PM   #5 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 71
halusha is an unknown quantity at this point
Default Re: UITableViewCell height set at cell creation

I think if you call reloadData on the UITableView, it will query the delegate (or datasource? can't remember) for the height of the row again. reloadData may end up calling viewWillAppear, in which case it wouldn't be any better of a workaround than the solution you already have. I'm not sure though.
halusha is offline   Reply With Quote
Old 10-22-2008, 02:37 AM   #6 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 8
phuongth is on a distinguished road
Default

Quote:
Originally Posted by jonc View Post
Do you need each cell to have a different height?
Can you do this?
Thanks a lot!
phuongth is offline   Reply With Quote
Old 10-22-2008, 08:04 AM   #7 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

You need to figure out the height of any dynamic height cells independent of the actual cell. This kind of sucks but that's the way it is. tableView:heightForRowAtIndexPath will be called at various times that you can't predict and it will certainly be called at times that some of your cells don't exist.

So if your cell has a variable amount of text in it or an image that can be different heights you need to determine the height of the content independently of the cell object itself.

If you have implemented heightForRowAtIndexPath: the tableview will call it for all of the rows in order to figure out the height of the entire table. It will do this every time that reloadData is called by your code.
PhoneyDeveloper is offline   Reply With Quote
Old 10-22-2008, 08:38 AM   #8 (permalink)
New Member
 
Join Date: May 2008
Age: 28
Posts: 65
paos is an unknown quantity at this point
Default

How can I get a textView's height before placing it on a cell?
paos is offline   Reply With Quote
Old 10-22-2008, 08:54 AM   #9 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

UITextView scrolls its contents to it can be any height you want.

Look at this thread for a way to determine the height of a string of text:

http://www.iphonedevsdk.com/forum/ip...h-strings.html
PhoneyDeveloper is offline   Reply With Quote
Reply

Bookmarks

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
UITableViewCell backgroundColor cacaodev iPhone SDK Development 15 11-23-2010 08:36 AM
SMS balloon cell?? javid.alimohideen iPhone SDK Development 23 04-02-2010 08:48 AM
Easily customize table cell. pendraggon87 iPhone SDK Development 4 07-04-2008 07:06 AM
Table cell refresh through timer mademo iPhone SDK Development 6 06-01-2008 01:43 PM
dynamic UITableViewCell creation sachinkumarlal iPhone SDK Development 1 05-19-2008 11:15 AM


» Advertisements
» Online Users: 421
16 members and 405 guests
Atatator, chiataytuday, condor304, dre, FrankWeller, imac74, ipodphone, jeroenkeij, kukat, LunarMoon, n00b, PowerGoofy, QuantumDoja, Retouchable, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,675
Threads: 94,124
Posts: 402,909
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Retouchable
Powered by vBadvanced CMPS v3.1.0

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