Objective-c – iOS 7 Table view fail to auto adjust content inset

ios7iphoneobjective cuitableview

I am transiting my project to iOS7. I am facing a strange problem related to the translucent navigation bar.

I have a view controller and it has a tableview as subview (let's call it ControllerA) . I init a new uinavigationcontroller with the controllerA and present it modally using presentviewcontroller. The presented view controller's table view is blocked by the navigation bar. I set the automaticallyAdjustsScrollViewInsets to YES but the result did not change.
I knew I can set the edgesForExtendedLayout to UIRectEdgeNone, but it will make the navigation bar no more translucent.

Table view get blocked

After that, I tried to create a new view controller for testing. It contains almost the same elements. But the result is much different. The table view content does not get blocked.

enter image description here

Conclusion

  1. Two View Controllers' automaticallyAdjustsScrollViewInsets set to YES
  2. The project is not using storyboard
  3. The first one is created at Xcode 4.6, The second one is newly created on Xcode 5
  4. I have compared two classes xib and code, not much different

Best Answer

I have found the answer on apple developer forum. There are two different case.

The first one, the view controller added is a UITableViewController. And the issue should not be appeared since apple will auto padding it.

The second one, the view controller is NOT a UITableViewController. And in the view hierarchy, it contains a UITableView. In this case, if the UITableview(or ScrollView) is the viewController's mainview or the first subview of the mainview, it will work. Otherwise, the view controller doesn't know which scroll view to padding and it will happen the issue.

In my case, the view controller is the second one. And there is a background image view as the first subview of the main view. So, it fails.

Here is the Apple developer forum link (need developer account to access): https://devforums.apple.com/message/900138#900138