我正在使用适用于 iOS 的 Google AdMob:
我想知道我是否能够以编程方式关闭这些广告,以便它们停止显示。阅读 SDK 后,我看不到任何地方可以打开或关闭广告。
编辑:
这是我加载 Google AdMob 代码的方式:
主视图控制器.m
- (void) viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// Create a view of the standard size at the bottom of the screen.
// Available AdSize constants are explained in GADAdSize.h.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
// Must be a better way to position at bottom of page
[bannerView_ setCenter:CGPointMake(kGADAdSizeBanner.size.width/2, 455)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
GADRequest *request = [GADRequest request];
// remove this line when you are ready to deploy for real
request.testing = YES;
[bannerView_ loadRequest:request];
}
我想在类实现中禁用超级视图:
这是迄今为止我尝试循环遍历MainViewController
子视图的代码。
一旦我找到了正确的子视图GADBannerView
,我希望能够将其删除。
其他类.m
- (void)disableAds
{
// Turn the ads off.
UIViewController *mainView = [[UIViewController alloc] initWithNibName:@"MainViewController" bundle:[NSBundle mainBundle]];
for (UIView *subview in [mainView.view subviews]) {
NSLog(@"View(s): %@", subview);
}
}