Big_Mac
Big_Mac

Reputation: 3034

Animation hangs when pushing UIViewController to UINavigationController

I have a custom UITableViewCell I created entirely in code. This project doesn't use autolayout at all, all drawing is done in code. When the user taps a button in my custom cell it calls a delegate which the UITableViewController implements and then pushes a new view controller to the navigation controller. It works fine, but when it's transitioning the animation freezes half way and then segues all at once as seen in this gif. I've worked on projects using storyboards and know it's not supposed to look like this. I've tried using dispatch_after and dispatch_async which lead to the same outcome. This is the code I'm using.

let vc = UIViewController()
self.navigationController!.pushViewController(vc, animated: true)

How can I fix this bug? Thanks in advance for any help!

Upvotes: 1

Views: 783

Answers (2)

adamjansch
adamjansch

Reputation: 1371

This can also happen if the view controller being pushed is a UITableViewController and the table view is hidden in the lifecycle at some point.

Look for tableView.isHidden = true in one of the overridden viewWill... or viewDid... methods and remove that line.

Upvotes: 0

Big_Mac
Big_Mac

Reputation: 3034

This bug is weird beyond understanding, but inserting the following line of code in the viewDidLoad of the viewController being shown fixed it.

        self.view.backgroundColor = UIColor.whiteColor()

Upvotes: 3

Related Questions