Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在多个视图控制器中共享我的广告横幅,但我不确定我应该如何去做。每个人似乎都在他们的视图控制器中创建 AdWhirlView,但是你每次都重新加载并且广告需要时间才能出现。我宁愿让它进来一次,然后在用户浏览我的视图控制器时共享广告视图。
您可以在您的应用程序委托(或任何其他全局可访问对象)中实例化视图,将其分配给一个属性,然后通过调用以下内容从应用程序中的任何位置访问它:
[[[UIApplication sharedApplication] delegate] myAdWhirlView]
视图已经实例化,然后您可以将其添加到您的超级视图并随意删除它,同时保持实例化。