我的第一个屏幕(ViewController)上有一个广告横幅,我想知道在其他屏幕(ViewControllers)上实现广告横幅的最佳方式是什么,这样我的应用程序就不会因为我做错了而被苹果拒绝-我有大约20个。
我只是简单地将横幅从第一个屏幕复制并粘贴到其他屏幕上,还是必须重写并添加一些代码
这是我在.h文件中的AdBanner代码
@interface ViewController : UIViewController <ADBannerViewDelegate>
@property (weak, nonatomic) IBOutlet ADBannerView *banner;
@end
这是我在.m文件中的AdBanner代码
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.banner.delegate = self;
}
- (void) viewDidLayoutSubviews {
if (self.banner.bannerLoaded) {
CGRect contentFrame = self.view.bounds;
CGRect bannerFrame = self.banner.frame;
contentFrame.size.height -= self.banner.frame.size.height;
bannerFrame.origin.y = contentFrame.size.height;
self.banner.frame = bannerFrame;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
NSLog(@"bannerViewActionShouldBegin");
return YES;
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"bannerViewDidLoadAd");
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"didFailToReceiveAdWithError");
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
NSLog(@"bannerViewActionDidFinish");
}
@end
非常感谢任何建议和帮助
从Apple获取iAdSuite示例代码,并查看ContainerBanner示例。这让你有一个地方,你有你的iAd代码和BannerViewContainer处理所有繁重的工作。