4

When I click one of the cells in the table view, it opens a new view with the following code:

   let fullResView : FullResponseViewController = self.storyboard?.instantiateViewControllerWithIdentifier("FullResponseView") as! FullResponseViewController
   fullResView.receivedPost = post
   self.navigationController?.pushViewController(fullResView, animated: false)

When I press back, it increases the distance between the table view and the Top Layout Guide. Representation:

table view navigation controller error.

Hierarchy:

  • I have a tab bar controller, that is embedded in a navigation controller.
  • The table view is drag & dropped after creating an normal view. So the table view is inside a View.
  • Table view does contain an header view. When setting a background color for this, it moves together with it, so it should not be anything with those constraints.

constraints for the table view are:

  • equal with to superview
  • Align Center X to superview
  • top space to Top Layout Guide
  • bottom space to Bottom Layout Guide

I've tried the following:

set this in viewWillAppear:

self.responsesTableView.contentOffset =  CGPointMake(0, 0)
self.automaticallyAdjustsScrollViewInsets = false

This did work when I pressed back, then switch to another view in the tab bar, and then switch back again. Without contentOffset it will stay like this forever.

CularBytes
  • 9,924
  • 8
  • 76
  • 101
  • 1
    try to set background color for the View that contains you table view, and let me see that which view the white space belong to ? – Gintama Sep 21 '15 at 13:22
  • the white space belongs to the View that contains the table view. Nitin Gohel, any suggestions? – CularBytes Sep 21 '15 at 13:30
  • Well Nitin, you can make this an answer, or Gintama, or togheter :) But I don't get it, nowhere in my workspace I could find something with `translucent`, still, setting this to false in app delegate did the trick...but why? – CularBytes Sep 21 '15 at 13:53

2 Answers2

12

As i seen the OP images that seems like Navigation translucent property Issue. Because after push a viewcontroller there is same 44px white space. so it means if your Navigation translucent property is true then your UITableview start from 0th Y position. And if your Navigation translucent property is false then UITableview start from 44px Y position.

So i guess in between push and back some where UINavigation's translucent become a true and false. make following one line add in your appdelegate class in DidFinish method:

UINavigationBar.appearance().translucent = false

This is appearance of UINavigationBar for make this false globley in your project. Hope that will be fix your issue.

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
0

I'm not sure if this is related to your particular issue, but it's worth checking whether your UITableView is the first control on your screen:

Why is there extra padding at the top of my UITableView

Even in the latest version of Xcode, this is a bug. But it's easy enough to fix, if you know how to get around it.

enter image description here

Community
  • 1
  • 1
Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159