简体   繁体   中英

Communication from SKScene to UIViewController

I'm using Google AdMob and to present ads, I do so from the ViewController . Right now, I have a button in my GameScene that is supposed to tell the ViewController to display the ads.

At first, I tried delegation, but that didn't work since SKScene already has a delegate, but then I stumbled upon this answer that showed a way for the SKScene to call a method in its ViewController . The answers seems sketchy, though, as the SKScene holds a reference to its ViewController . My understanding, as well as according to this , was that this is bad practice, assuming that in my case, the SKScene is the View in the MVC structure.

So how should I notify the ViewController of events occurring in the SKScene ?

您可以检查我的答案 ,该答案描述了如何使用委托模式将SKScene与UIViewController进行通信。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM