0

This is what I do now:

func presentOverlayController(controller: UIViewController) {

    controller.modalPresentationStyle = .Custom
    controller.transitioningDelegate = self

    presentViewController(controller, animated: true, completion: nil)
}

//MARK: - UIViewControllerTransitioningDelegate

public func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
    return OverlayPresentationController(presentedViewController: presented, presentingViewController: presenting)
}

It works pretty awesome. First I get the controller from storyboard using .instantiateViewControllerWithIdentifier:. Controller is presented the right way:

enter image description here

But the same result I need to achieve with my custom segue:

class OverlaySegue: UIStoryboardSegue, UIViewControllerTransitioningDelegate {

    override func perform() {

        destinationViewController.modalPresentationStyle = .Custom
        destinationViewController.transitioningDelegate = self
    }

    //MARK: - UIViewControllerTransitioningDelegate

    func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
        return OverlayPresentationController(presentedViewController: presented, presentingViewController: presenting)
    }
}

but it doesnt work. Why?

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358

1 Answers1

1

At the end of perform you need to call presentViewController(destinationViewController, animated: true, completion: nil).

Viktor Simkó
  • 2,607
  • 16
  • 22