A: 

Create a class that subclasses UITableviewcell in your project. Create this class' nib and set its parent to be the class in your project with tableview and override its -

(void)setSelected:(BOOL)selected animated:(BOOL)animated 

Write methods contractCell() and expandCell() in this class, and provide the height of the cells you want in expandCell method. Call this methods appropriately based on some flags set to identify wheather the cell is in expanded state or contracted state. Use your tableview's

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

method to handle selection of cells.

neha
neha, thx for your reponse. Could you elaborate a little on how exactly to go about this? Im still a little confused on how to use the setSelected: method? Will the tableCell automatically adjust it height after calling expandCell/contractCell and more importantly would it appear as if the selected cell is expanding and not simply being reloaded which is the initial problem i ran into? I called reoloadRowsAtIndex in didSelectRowAtIndex and while that worked you could visually see the cell being reloaded, either from the top/bottom/etc. depending on the animation style chosen.
s.newave
Once you create a class that subclasses uitablviewcell, the method "(void)setSelected:(BOOL)selected animated:(BOOL)animated" automatically appears in the created class which is explicitely called whenever you select a cell in tableview. It's meant for configuring the view for selected state of cell. Make sure to also create a nib of this uitableviewcell subclass and set the parent of this nib as your tableview's class. Yes, this will give you the effect you are expecting, it will show the cells expanding/contracting and not reloading.
neha
hi neha, thx again for replying. I seem to be making some progress however pls see above for changes i have tried and issues i am still having. Also what code exactly should go into the setSelected: method? Still trying to stumble through this unfortunately.thx
s.newave
The contents [labels, textfield etc] you want to show in your cell should be configured in tableview delegate method - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath). Keep the selected "height" logic in (void)setSelected:(BOOL)selected animated:(BOOL)animated. In expandCell() and contractCell(), only assign the cell its height and call these methods in setSelected method mentioned above. If you want dynamic height for your subviews then it also should be handled in the tableview delegate method cellForRowAtIndexpath mentioned above.
neha
I made the changes you suggested which are shown above however the problem now is that the cell, while expanding, does not update to show the new label, textfields, etc.. This is why i initially put all the cell content stuff in expandCell because even though i call [tableView beginUpdates] in didSelectRowAtIndex the cellForRowAtIndex method is NOT called at all. Now that i have moved all the new cell content creation code back into that method it doesnt update the cell until it is shown again. Also not sure if i am correctly setting the height for the cell in expandCell:?
s.newave
The cell text instead is being squashed and stretched. Arggg! This is driving me nuts, please can you show me some code on how to get this working :) thx
s.newave
I'm afraid why your cellForRowAtIndex method isn't getting called. Are you setting the tableview delegate to self? When I had done something similar I wasn't using [tableView beginUpdates], [tableView endUpdates]. Try removing them. Regarding the code, I'll try posting it tonight.
neha
That would be GREAT if you could post some code, thx!!
s.newave
I'm sorry for such a big delay.. Thought I would develop it myself and suggest you better, but i'm very busy to even sleep... Check this stackOverflow question:http://stackoverflow.com/questions/2810653/first-tap-on-customcell-of-uitableview-should-expand-it-and-second-should-contrac. To be clear, this question's asked by me when I was working for my earlier employer, so I don't have the code any more..
neha
A: 

The Apple way to do is quite simple.

First, you'll need to save the selected indexPath row:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   self.selectedRowIndex = [indexPath retain];
   [tableView beginUpdates];
   [tableView endUpdates];
}

I'll explain the begin/end updated part later.

Then, when you have the currently selected index, you can tell the tableView that it should give that row more space.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   //check if the index actually exists
   if(selectedRowIndex && indexPath.row == selectedRowIndex.row) {
        return 100;
   }
   return 44;

} This will return height 100 for the selected cell.

Now we can go back to the begin/end updates. That block triggers the reload of all tableView geometry. Moreover, that block is animated, which eventually gives the impresions of the row expanding.

Hope this was helpful, Pawel

Pawel
hi Pawel, tried this and the animation affect is exactly what i am looking for but the issue i ran into is that this code does not call cellForRowAtIndex so i couldnt figure out how/where to modify the content of the expanded cell. It simply adjusts the height of the cell. I also tried to get the cell in didSelectRowAtIndex with:UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];and make changes to the cell and then call beginUpdates. While this works it seems to wreak havoc on the rest of the table. Can you explain where you make changes to the selected cell to avoid this?
s.newave
Since you're calling the begin/end updates in didSelectCellForRowAtIndexPath: method, the cell has already been selected. Therefore you can use the setSelected:animated: method in your cell implemenetation to configure it for selected state.
Pawel
s.newave
Hi Pawel, Any ideas on why this isnt working properly. Could you please give me some code snippets or something? I reeeeally want to move on to something else now :)
s.newave
The begin/end updateds is the right way to do this. Don't add new views o setSelected. Instead, add them on cell creation, and set their hidden value to YES. Layout them properly in your implementation of layoutSubviews. And when you're selecting the cell, set their hidden to NO, and when deselecting to YES. There is no need for you to get the cellForRowAtIndexPath method called. You can do all the customization without it. Kind Regards, Pawel
Pawel