20

I'm very new to iOS. I have a UITableView that filled with many custom cells, but the bottom cell is is not visible properly when scroll down.my Y value of the UITableView is 44 and Height is 480. Only the half of the last cell is visible when scroll down. How can I fixe this problem.

Thanks in advance.

iDia
  • 1,397
  • 8
  • 25
  • 44

5 Answers5

74

Use -

  tableView.contentInset = UIEdgeInsetsMake(0, 0, 120, 0); //values

passed are - top, left, bottom, right

Pass bottom offset as per your needs.

codercat
  • 22,873
  • 9
  • 61
  • 85
rishi
  • 11,779
  • 4
  • 40
  • 59
5

it is because you set your tableview's frame wrong, if your view has a navigation bar , usually use this code:

CGRect frame = self.view.bounds;
frame.height -= 44;

44 is the height of your navigation bar.

jianpx
  • 3,190
  • 1
  • 30
  • 26
1

If you have a status bar visible on the top, then it will occupy 20px which will push down your tableView by the same. To avoid this, make the tableView height 460 instead of 480.

ashokbabuy
  • 1,000
  • 10
  • 17
  • 1
    You shouldn't hardcode the status bar height value though, something like in this answer should be used instead http://stackoverflow.com/a/7038870/707983 – Henri Normak Aug 13 '12 at 04:28
1

For me this is worked.

I have commented out my code

-(void)viewWillLayoutSubviews
{
dispatch_async(dispatch_get_main_queue(), ^{
    //This code will run in the main thread:
    CGRect frame = tableViewObj.frame;
    frame.size.height = tableViewObj.contentSize.height;//commenting this code worked.
    tableViewObj.frame = frame;

});

}

That's it. It worked for me. Please make sure you have not changed tableview frame some where while in implementation file.

Narasimha Nallamsetty
  • 1,215
  • 14
  • 16
0

If you are on iOS7 and using a navigation controller toolbar, make sure to set it to translucent:

    self.navigationController.toolbar.translucent = NO;
ebi
  • 4,862
  • 6
  • 29
  • 40