简体   繁体   English

如何关闭 iOS Swift SKOverlay?

[英]How can I dismiss an iOS Swift SKOverlay?

I read about how to create an SKOverlay to cross promote an app here: https://sarunw.com/posts/cross-promote-apps-with-skoverlay/我在这里阅读了有关如何创建 SKOverlay 来交叉推广应用程序的信息: https://sarunw.com/posts/cross-promote-apps-with-skoverlay/

But the view seems to stay visible when after a segue to another view controller.但是,在切换到另一个视图 controller 之后,该视图似乎仍然可见。

So I would like to dismiss the SKOverlay promotional banner when the view that is displaying it disappears.因此,当显示它的视图消失时,我想关闭 SKOverlay 促销横幅。

They way to do this is to call a function like this in viewWillDisappear:他们这样做的方法是在 viewWillDisappear 中像这样调用 function:

@available(iOS 14.0, *)
  private func dismissOverlay() {
    guard let scene = view.window?.windowScene else {
      return
    }
    SKOverlay.dismiss(in: scene)
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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