Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView is starting with an offset in iOS 7

The new iOS 7 implementation of UIViewController has a new set of options that allows the developer to choose if the system will automatically add insets for UIScrollView, UITableView and derivations.

To disable this behaviour uncheck these boxes for all your wanted UIViewControllers in InterfaceBuilder, on UIViewController selected object inspector:

View Controller Inspector

For more details:

  1. Submit your iOS 7 apps today.
  2. iOS 7 UI Transition Guide > Appearance and Behavior

By default table view controllers will pad the content down under the nav bar so you could scroll the content under it and see it, in a blurred state, underneath the navbar/toolbar.

Looks like you're positioning it at 44 (maybe 64)px to move it out from under the nav bar, but it already compensates for this so you get a big gap.

Go to the storyboard/xib in IB and untick the show content under nav bar stuff.


From iOS7 transition guide:

If you don’t want a scroll view’s content insets to be automatically adjusted, set automaticallyAdjustsScrollViewInsets to NO. (The default value of automaticallyAdjustsScrollViewInsets is YES.)

   self.automaticallyAdjustsScrollViewInsets = NO;

i had a similar problem, after dismissing a viewController, the contentOffset from my tableView was changed to (0, -64).

my solution was a little weird, i tried all the other answers but had no success, the only thing that fixed my problem was to switch the tableView position in the controls tree of the .xib

it was the first control in the parent View like this:

before

I moved the tableView right after the ImageView and it worked:

after

it seems that putting the table view in the first position was causing the trouble, and moving the table view to another position fixed the problem.

P.D. I'm not using autoLayout neither storyboards

hope this can help someone!


it resolve my similar problem:

if ([[UIDevice currentDevice].systemVersion floatValue] >= 7){
tableView.contentInset = UIEdgeInsetsMake(-20, 0, 0, 0);
}

Try using this

tableView.separatorInset = UIEdgeInsetsZero;

Obviously, if you're supporting anything less than iOS7 you will need to ensure that the object responds to this selector before calling it.