目前我使用此代碼來加載iAD橫幅。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中有改變旋轉行爲,看到這裏例如http://stackoverflow.com/questions/12536645/rotation-behaving-differently-on-ios6。當界面旋轉時,再次設置adbanner框架。 – 2013-02-18 11:39:58