13

Setting the contentInset on a UITableView doesn't seem to work on iOS 7:

self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); 
// Works on iOS 6, nothing happens on iOS 7

I've tried setting self.automaticallyAdjustsScrollViewInsets to NO in viewDidLoad, still nothing.

What am I doing wrong? Is there a new way to do this or a workaround?

nathan
  • 1,456
  • 1
  • 15
  • 32

1 Answers1

32

Moving this code into the view controller's -viewDidLayoutSubviews method fixed this for me.

-(void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); 
}

Thanks Apple for your non-existent documentation on this!

nathan
  • 1,456
  • 1
  • 15
  • 32
  • Thanks for this, it seems the default content inset isn't set in viewWillAppear but it is by the time this method is called. I was trying to move a view to the bottom of the screen and this helped. – malhal Feb 12 '14 at 18:35