P. Pawluś P. Pawluś - 4 months ago 11
iOS Question

UIPresentationController is being presented after huge delay

This is how I present my custom

UIPresentationController
:

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)
}


I present my controller once I tap on
UITableViewCell
. It is presented very quickly only if I tap on cell twice. However, when I perform single tap, then it works as well but with huge delay (between 15-60 seconds).

What is the reason?
How to workaround it?

Answer

There is a known bug with didSelectRowAtIndexPath that occurred to me as well, and this is the workaround I used.

Try to do this inside your didSelectRowAtIndexPath:

dispatch_async(dispatch_get_main_queue(), {
    presentOverlayController(......)
})

References: