views:

82

answers:

2

I am new to iphone development.I am parsing a xml file and displaying the title, date, view and summary in each row of a table.The contents of summar is big ,so only first 3 words are displayed in the cell.How can i increase the height of the row with respect to the length of the contents.All the content should fit properly inside the cell and full content should be displayed.Please help me out.Thanks.

A: 

One way to do it is to manually set the size of the cell. Just replace ROW_HEIGHT with something suitable.

cell.frame = CGRectMake(0.0, 0.0, 320.0, ROW_HEIGHT);
willcodejavaforfood
I want to change the height of only one row and not all the row.
Warrior
You could only do it for this cell...
willcodejavaforfood
+2  A: 

You can do this in your tableView.delegate/datasource:

- (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   switch (indexPath.row){
       case 0:
         if(indexPath.section==0)
            return 123.0; // first row is 123px high
       default:
         return 40.0; // all other rows are 40px high 
   }
}

This does however slow down scroll performance. Ideally you should set the row height for all rows to be identical using tableview.rowHeight.

Felix
I want to increase the height of a single row which displays summary
Warrior
The return a different number depending on the NSIndexPath.
Felix
can you elaborate your answer please.since i am new to iphone i am not able to understand it.
Warrior
I have added a bit more code. It's pretty straight forward
Felix
Thanks its working, what should i do, if i use grouped tables and consisting 2 tables.I want to increase the height of the first cell of first table only..
Warrior
I added a check for the first section.
Felix
Thanks it works fine....
Warrior