目前我使用它来编写加载 iAD 横幅的代码。
- (void)viewDidLoad
{
[super viewDidLoad];
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height;
adView.frame = adFrame;
[adView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:adView];
adView.delegate=self;
self.bannerIsVisible=NO;
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
adView.frame = adFrame;
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height+adView.frame.size.height;
adView.frame = adFrame;
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
问题是我想在设备方向改变时也将 iAD 视图自动设置到视图的底部。我尝试了很多东西,但都没有奏效。
另外为什么我必须使用通知中心来检查设备方向?DidRotateToInterfaceOrientation
似乎不起作用。