此外,添加iAd和AdMob代码以使横幅显示在屏幕上,以下代码是设置共享横幅的正确方法吗?
在AppDelegate.h中
@import GoogleMobileAds;
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property(nonatomic, strong) ADBannerView *iAdView;
@property(nonatomic, strong) GADBannerView *adMobView;
@end
AppDelegate.m
#import "AppDelegate.h"
#import <iAd/iAd.h>
@implementation AppDelegate
@synthesize iAdView;
@synthesize adMobView;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
iAdView= [[ADBannerView alloc]init];
return YES;
}
iPhone6.m
#import "iPhone6.h"
#import <iAd/iAd.h>
#import "AppDelegate.h"
-(AppDelegate *) appdelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
-(void)viewDidLoad{
iAdView =[[self appdelegate] iAdView];
}