0

I have one UItableview and I have one customCell for printing the data in the UITable.

Now, I want to put more data in specific cell. When I select on cell, it should increase the height of cell and put that data. How is it possible.?

joaquin
  • 82,968
  • 29
  • 138
  • 152
Ankit
  • 286
  • 4
  • 16

4 Answers4

0

In DidSelect make the height of particular selected cell to your required cell.

And reload the table.

This is helpful : How to programmatically increase UITableView cell's height in iPhone?

Community
  • 1
  • 1
Samkit Jain
  • 2,523
  • 16
  • 33
  • Thank You, But when i am select on cell at that time the particular custom cell is expanding in the tableview and print the data. in 'heightforRowatIndexPath' check the condition is particular index is selected or not. if selected than height is increasing otherwise default height is printed. – Ankit Feb 25 '14 at 07:40
  • Reload table there and in cellForRow based on selcted cell, show the data' – Samkit Jain Feb 25 '14 at 07:58
0

Call reload table data by changing the parameters of row and to find the height of a cell after adding data use:

CGSize size=[youstring sizeWithFont:yourlabel.font constrainedToSize:labelfontsize lineBreakMode:lineBreakmodestyle];

And get height from size.height and return the height in heightForRowAtIndexPath method while reloading tableview.

0

what you should do is First Calculate the Size of your content for which you have to increase the cell height

//Suppose here is your string which you want to show
-(float) calculateHeight:(NSString *)dataStr
{

    CGSize size = [dataStr sizeWithFont:[UIFont fontWithName:@"Helvetica" size:17] constrainedToSize:CGSizeMake(280, 999) lineBreakMode:UILineBreakModeWordWrap];
    NSLog(@"%f",size.height);
    return size.height + 10;
}

This Above function will return the height according to your Text Size.

Now just have to call this function on the

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

}

delegete and reload the tableview and give the size you calculated with the above function at heightForRowAtIndexPath delegete.

BhavikKama
  • 8,566
  • 12
  • 94
  • 164
0

Try this sample if I've understood what you want: https://github.com/Dmitriy837/changeTableRowHeighWhenTaped

I suggest you subclass UITableView and support additional property with cell heights in it and change the cell's height when it's taped.

user2260054
  • 522
  • 1
  • 3
  • 11