0

I have a UITableView that scrolls up too far, to the point where the list of items in the UITableView scroll up and then a large amount of whitespace follows it.

How can I stop UITableView from scrolling that extra space?

Hope I described it well enough.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
hanumanDev
  • 6,592
  • 11
  • 82
  • 146

2 Answers2

2

I think this may work for you. Run this code after calling reloadData on the table :

if (table.contentSize.height < table.frame.size.height) 
{
   table.scrollEnabled = NO;
}
else 
{
   table.scrollEnabled = YES;
}

Here ,table.frame.size.height is the actual size of the object (you can see this in Interface Builder) displayed on the screen, whereas table.contentSize.height is the height of the header, the footer, and the height of every cell added together.

I found it here : How to disable scrolling in UITableView table when the content fits on the screen

Hope you can get something from the answers given their also.

Community
  • 1
  • 1
Bhavin
  • 27,155
  • 11
  • 55
  • 94
1

This will fix your problem

TableView.bounces=NO;

This will remove empty cells

TableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127