多个视图控制器上的 iAd
我以前使用过 iAd,但仅适用于具有单个视图控制器的应用程序。但我似乎无法弄清楚如何在 AppDelegate 中创建对广告的全局引用,并从那里为我单独的视图控制器获取它(这就是我读过的我应该做的)。
我一直在寻找有关此事的教程,但由于某种原因我找不到任何相关内容。
有什么提示吗?给我指明正确的方向吗? :)
蒂亚! /马库斯
I have used iAd's before but only for apps with a single view controller. But I cannot seem to figure out how to create a global reference to the ad in the AppDelegate and fetch it from there for my separate view controllers (That's what I've read I'm supposed to do).
I've been searching for a tutorial on the matter, but for some reason I can't find anything relevant.
Any hints? Point me in the right direction? :)
TIA!
/Markus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在应用程序中有一个 adddelegate.h 和 .m 文件。您在 delegate.m 文件中添加 iad 并在其他视图中创建引用:
在 Appdelegate.h 添加 delegate :
@interface AppDelegate : UIResponder
ADBannerView *bannerView;
@property(非原子,保留)ADBannerView *bannerView;
在Appdelegate.m中:
@synthesizebannerView;
{
bannerView = [[ADBannerView alloc]initWithFrame:CGRectZero];
bannerView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifierLandscape,nil];
bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
横幅视图.delegate = self;
现在,
您在其他类 viewdidload 中创建 Appdelegate 的引用:
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication ]delegate];
In applications there is a adddelegate.h and .m file. You add iad in delegate.m file and create reference in other view :
in Appdelegate.h add delegate :
@interface AppDelegate : UIResponder
ADBannerView *bannerView;
@property (nonatomic, retain) ADBannerView *bannerView;
in Appdelegate.m :
@synthesize bannerView;
{
bannerView = [[ADBannerView alloc]initWithFrame:CGRectZero];
bannerView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifierLandscape,nil];
bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
bannerView.delegate = self;
}
Now you create reference of Appdelegate in other class viewdidload :
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication ]delegate];