Skip to content

Commit

Permalink
Fix wrong execution order child view controller embedding methods (52…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrylmz authored and amyleecodes committed Jul 13, 2017
1 parent 59961d7 commit c464795
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions PulleyLib/PulleyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,26 @@ open class PulleyViewController: UIViewController {
willSet {

guard let controller = primaryContentViewController else {
return;
return
}

controller.view.removeFromSuperview()

controller.willMove(toParentViewController: nil)
controller.view.removeFromSuperview()
controller.removeFromParentViewController()
}

didSet {

guard let controller = primaryContentViewController else {
return;
return
}


addChildViewController(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = true

self.primaryContentContainer.addSubview(controller.view)
self.addChildViewController(controller)
controller.view.frame = primaryContentContainer.frame
primaryContentContainer.addSubview(controller.view)
controller.didMove(toParentViewController: self)

if self.isViewLoaded
{
self.view.setNeedsLayout()
Expand All @@ -151,28 +151,28 @@ open class PulleyViewController: UIViewController {
/// The current drawer view controller (shown in the drawer).
public fileprivate(set) var drawerContentViewController: UIViewController! {
willSet {

guard let controller = drawerContentViewController else {
return;
return
}

controller.view.removeFromSuperview()

controller.willMove(toParentViewController: nil)
controller.view.removeFromSuperview()
controller.removeFromParentViewController()
}

didSet {

guard let controller = drawerContentViewController else {
return;
return
}


addChildViewController(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = true

self.drawerContentContainer.addSubview(controller.view)
self.addChildViewController(controller)
controller.view.frame = drawerContentContainer.frame
drawerContentContainer.addSubview(controller.view)
controller.didMove(toParentViewController: self)

if self.isViewLoaded
{
self.view.setNeedsLayout()
Expand Down

0 comments on commit c464795

Please sign in to comment.