P. Pawluś
P. Pawluś

Reputation: 318

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?

Upvotes: 1

Views: 232

Answers (2)

Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61814

Try this:

dispatch_async(dispatch_get_main_queue()) {
    self.presentViewController(controller, animated: true, completion: nil)
}

Upvotes: 0

Alessandro Orrù
Alessandro Orrù

Reputation: 3513

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:

Upvotes: 2

Related Questions