16

I want to make a UITableViewCell bigger. How can I do this, I have tried adjusting its frame but nothing happens. What can I do?

jszumski
  • 7,430
  • 11
  • 40
  • 53
user973985
  • 291
  • 2
  • 7
  • 14

5 Answers5

36

You need to implement the

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

method in your UITableViewDelegate.

Shane Powell
  • 13,698
  • 2
  • 49
  • 61
18

You can do like this..

//Change the Height of the Cell [Default is 44]:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
  if (indexPath.section == 0) {
   if (indexPath.row == 1) {
     return 90;
   }
  }
  return 44;
}

I hope this will help you..

User-1070892
  • 929
  • 10
  • 16
8

There are 2 steps to change height of a table cell without any additional code:

  1. Select your Table View from your Storyboard. In the Size Inspector change Row Height.
  2. Select your Table View Cell and while it's selected in the Size Inspector change the Row Height.

Note that you MUST set BOTH of Table View's Row Height attribute and Table View Cell's Row Height attribute.

If you just set one of them, it won't work.

scaryguy
  • 7,720
  • 3
  • 36
  • 52
0

I found this answer to be the most informative and most up-to-date to change the height of a table view cell.

TL;DR

  1. Take extra care when making your Auto Layout constraints
  2. Enable row height estimation on your table view in the viewDidLayoutSubviews method.

    self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 44.0; // set to whatever your "average" cell height is

Community
  • 1
  • 1
ChrisJF
  • 6,822
  • 4
  • 36
  • 41
  • This is a late answer to an old question. If you feel that this question is a duplicate, it should be flagged as such. – JAL Dec 14 '15 at 17:46
-2

You can use this code for changing the height of different tableview

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView == tableView1) 
    {
        return 55;
    }
    else if(tableView == tableView2)
    {
        return 75;
    }
}

This may help you.

viral
  • 4,168
  • 5
  • 43
  • 68
Nithinbemitk
  • 2,710
  • 4
  • 24
  • 27