Reputation: 1199
I'm currently using SWRevealViewController with Storyboards and I'm seeing a behavior I didn't see until recently.
Originally, in one of my front view controllers, I was using a UITableViewController and it worked fine. However, I needed to swap it out and replace it with a UIViewController with an MKMapView and a UITableView instead. I embedded the new view controller in a navigation controller using the Editor > Embed In > Navigation Controller as I had done previously with the UITableViewController.
Now I'm finding that when the second time the transition to the new front controller occurs, the content gets pushed down.
I put some logging in the ViewWillAppear method and see the following (edited to sift out logging noise...):
First Appearance
self.view - UIView: frame = (0 0; 320 568)
self.mapView - MKMapView: frame = (0 65; 320 128)
self.tableView - UITableView: frame = (0 193; 320 375)
Second Appearance
self.view - UIView: frame = (0 64; 320 504)
self.mapView - MKMapView: frame = (0 65; 320 128)
self.tableView - UITableView: frame = (0 193; 320 375)
So it appears that the child controls' X and Y coordinates are fine - they're the same in both appearances. However, the view controller's self.view is getting pushed down the second time around.
Any ideas as to why this might be happening, and what I can do to fix it? Overtly setting the view controller's view to 0,0 in viewWillAppear is not working for me.
Thanks in advance.
UPDATE Well... apparently the question is really: "why is the view's origin at 0,0 the first time?"
When I do logging on the other view controllers that I'm showing in the SWRevealViewController's front view, they generally report their origins at 0,64. However the first time the initial view controller is loaded and shown it's at 0,0... so now I'm wondering what's going on with that.
Upvotes: 0
Views: 851
Reputation: 131
After hours spent on this exact issue, I have found the solution.
In your initial navigation controller, you must set the nav bar to translucent. You can do this in storyboard by checking the "Translucent" checkbox, as pictured.
You can still apply a color (bar tint) to your nav bar, if desired.
Upvotes: 1
Reputation: 1199
OK... well... I found a solution. Feels kludgey, but works.
I deleted the root view in the view controller and replaced it with a UIScrollView, then embedded all the constituent controls inside the scroll view.
So this tells me that somewhere in the view controller chain that the "automaticallyAdjustsScrollViewInserts" may have been getting in the way somewhere? Or perhaps some Auto Layout quirk?
Still open to ideas if anyone has them since the Scroll View hack doesn't sit really well with me but I'll take it for now...
Upvotes: 0