ykyouhei/KYDrawerController

Weird margins when using async task

Open

#82 opened on Jan 19, 2017

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Swift (156 forks)github user discovery
help wantedpossible bug

Repository metrics

Stars
 (619 stars)
PR merge metrics
 (PR metrics pending)

Description

I'm having problem with margins when I instantiate a view controller inside an async task.

When I do this, the view loads weird:

let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0)) {
//Web Service call
dispatch_async(dispatch_get_main_queue()) {
   let viewController = UIStoryboard(name: "Tracking", bundle: nil).instantiateViewControllerWithIdentifier("tracking") as! CarrierTrackingVC
   viewController.truckTrack = TruckTrack()
   elDrawer.mainViewController = viewController
   }
}

screen shot 2017-01-18 at 9 48 30 am

But when I do it outside the async task it looks ok: screen shot 2017-01-18 at 9 50 16 am

I'm loading it in the main thread, inside dispatch_async(dispatch_get_main_queue()) so I don't understand why it behaves like that.

viewController is a UITabBarController, each tab contains a NavigationController, and each NavigationController contains a ViewController

UITabBarController > NavigationController > ViewController

Contributor guide