UITableView not scrolling to the bottom

12,769

Solution 1

Not being able to scroll to the bottom of the tableview is usually a symptom of its height being too large. (i.e. it's cut off at the bottom)

Don't compute the height you need and put those numbers in your code. Just find out what it should be from the view hierarchy. For example, you might compute the height of your table view with CGRectGetHeight(self.view.bounds) - CGRectGetMaxY(self.iAdView), and the view's y origin with CGRectGetMaxY(self.iAdView) assuming that the iAd view and your table view are both subviews of self.view. Or, even better, just use autoresize masks or autolayout to keep the table view the right size.

Solution 2

You can try

self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 44, 0);

Solution 3

I just had this embarrassing scenario where my UITableView would "bounce" but it wouldn't scroll to the bottom. For ME, the problem was that I was dynamically setting the row heights, and my very last cell was getting calculated with a cell height of -115 (yes, negative). Once I fixed that to return a positive number, my scrolling worked just fine.

Solution 4

Even we can achieve the same in storyboard.

Select tableView --> from the storyboard control click on 'add Missing constraints'. That will add the constraint to tableView and View.

That helped me to resolve this issue. Screenshot_Link

Share:
12,769
Marcal
Author by

Marcal

Updated on July 27, 2022

Comments

  • Marcal
    Marcal almost 2 years

    I have a UITableView (on a UIViewController) on which I want to ad an iAd banner on the top, but below a toolBar I already have on the top. I'm trying to shift the the tableView (in reference to the view) so I can locate the banner in the space left blank.

    To check it ou, I create an action in which I shift the tableView frame:

      -(IBAction)iAdAction:(id)sender{
    
       self.tableViewConc.frame=CGRectMake(0, 94, 320, 367);}
    

    where 94 is the summ of 44 from the toolbar and the 50 from the banner.

    The action works correctly but then, I cannot scroll to the bottom of the tableView, when I try it, it bounces back. I've tried to change the height of the tableView in the same action ( 430 instead of 367, for instance) but it doesn't work. I've also tried it on IB, but it doesn't work either.

    I feel that I'm missing something but I cannot remember what.

    Any help?

    Thanks in advance!

  • Marcal
    Marcal over 12 years
    I just implemented this, just below the line of code I show above [self.tableViewConc setContentSize:CGSizeMake(320, 420)]; and it works like a charm. Is it the same as you seggested?
  • Max Steinmeyer
    Max Steinmeyer over 10 years
    No, you should not change the content size of a table view directly; the UITableView class manages that based on the cell counts & heights you supply to it.
  • thandasoru
    thandasoru about 9 years
    Worked for me, and I'm using Autolayout with size classes. I would mark this as the correct answer.
  • apollow
    apollow over 8 years
    If you are still seeing a cutoff, it has to do with the status bar's height as well, consider "UIEdgeInsetsMake(0, 0, 64, 0);" instead.
  • NSNoob
    NSNoob almost 8 years
    Also if you are using retina devices, the bottom edge has to be doubled i.e. 88.