为什么我在关闭视图控制器后无法显示我的 Facebook 插页式广告?

Why cant I show my facebook interstitial ad after dismissing a view controller?

我正在使用 ReplayKit,当我按下取消或保存按钮时,它关闭了视图控制器,我想展示一个广告。问题是广告没有显示,我收到此错误:如何解决?谢谢!

Warning: Exception caught during invocation of received message, dropping incoming message and invalidating the connection. Exception: This method must be called on the main thread

internal func previewControllerDidFinish(previewController: RPPreviewViewController) {

previewViewController.dismissViewControllerAnimated(true, completion: nil)

NSNotificationCenter.defaultCenter().postNotificationName("loadAd", object: nil)

}

所有UI相关操作必须在主线程中完成。你可以使用 GCD 做这样的事情:

dispatch_async(dispatch_get_main_queue()) {
        previewViewController.dismissViewControllerAnimated(true, completion: nil)
}

您还可以post在 dismissViewControllerAnimated

的完成块中通知