views:

689

answers:

1

hey, we have a UITableView inside which we have (obviously) many UITableViewCells. We need to implement an action so that when the user touches the cell, the cell grows and shows more information. if the user touches the cell again, it resizes back to the original size.

We were able to implement this by changing the height of the frame of the cell like this:

CGRect newFrameTemp = self.frame;
newFrameTemp.size.height +=textHeight;
self.frame = newFrameTemp;

and also moving all the other cells textHeight pixels down. (and also changed the size of the table itself)

This seemed to work, only that the 'touch' events did not move together with the cells so that if I want to touch the next cell i actually need to touch the middle of the cell that we just 'opened'

any clues on we are doing wrong?

+1  A: 

Perhaps try to adjust the height using the UITableViewDelegate method:

– tableView:heightForRowAtIndexPath:

http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableViewDelegate%5FProtocol/Reference/Reference.html#//apple%5Fref/occ/intf/UITableViewDelegate

This may adjust the hit areas properly for you.

Edit: I just ran across this link which might be relevant: http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/

Ben Scheirman
Hey Ben, we actually did try that and it did not work, but we will try again..
Nir Levy
Hey, well, no. It's not working. heightForRowAtIndexPath gets called only on table creation. What we are doing is do change the cell's height dynamically when the user touches it.
Nir Levy
Surely tableView:heightForRowAtIndexPath: gets called when you reload the table view as well? Adjust the height in that method then call [tableView reloadData] perhaps?
Alasdair Allan
Nir Levy