20
votes

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.

5

5 Answers

72
votes

Use -

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

passed are - top, left, bottom, right

Pass bottom offset as per your needs.

5
votes

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.

1
votes

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.

1
votes

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.

0
votes

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

    self.navigationController.toolbar.translucent = NO;