【发布时间】:2013-02-10 22:43:00
【问题描述】:
目前我使用它来编写加载 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 似乎不起作用。
【问题讨论】:
-
在 iOS 6 中,旋转行为发生了变化,例如 stackoverflow.com/questions/12536645/… 。界面旋转时,重新设置adbanner frame。
标签: objective-c cocoa-touch iad device-orientation