Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView not scrolling to the bottom

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!

like image 265
Marcal Avatar asked Nov 27 '11 19:11

Marcal


2 Answers

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.

like image 99
Jesse Rusak Avatar answered Oct 23 '22 09:10

Jesse Rusak


You can try

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

like image 12
vishnu Avatar answered Oct 23 '22 09:10

vishnu