我有一个iAd,它显示在主 View 的全屏 subview 的顶部。 iAd在纵向模式下可以正常工作,我已经将iAd横幅 View 旋转为横向模式。当用户在横向模式下点击iAd时,就会发生此问题。测试广告在手机侧面以纵向显示,并且当用户点击x以关闭iAd时,横幅 View 及其父 View 被推离屏幕。 iAd在纵向模式下正常运行(即,点击并关闭它会导致包含横幅的 View 正常显示)。
我尝试过的事情:
- (void)bannerViewActionDidFinish:(ADBannerView *)banner{
NSLog(@"Ad was closed, show the adView again");
if(UIInterfaceOrientationIsLandscape(currentInterfaceOrientation)){
[self animateRotationToLandscape:0.3f];
}
else{
[self animateRotationToPortrait:0.3f];
}
}
-(void)animateRotationToPortrait:(NSTimeInterval)duration{
self.adView.currentContentSizeIdentifier =
ADBannerContentSizeIdentifierPortrait;
BOOL iPad = NO;
#ifdef UI_USER_INTERFACE_IDIOM
iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#endif
if (iPad) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
proUpgradeDescription.frame = CGRectMake(82,313,604,110);
proUpgradePrice.frame = CGRectMake(313,576,142,28);
closeButton.frame = CGRectMake(348,834,72,37);
purchaseButton.frame = CGRectMake(313,431,142,142);
[UIView commitAnimations];
}
else{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
proUpgradeDescription.frame = CGRectMake(20,80,280,70);
proUpgradePrice.frame = CGRectMake(88,322,142,28);
closeButton.frame = CGRectMake(123,403,72,37);
purchaseButton.frame = CGRectMake(88,172,142,142);
[UIView commitAnimations];
}
}
哪个调用我用来为纵向和横向模式的显示旋转动画的代码。此代码无效。
如果有人对为什么测试广告不能正确旋转以及为什么将其推离屏幕的父 View Controller 有任何想法,我将不胜感激。
最佳答案
我不知道这是否可以解决您的所有问题,但是根据this question的答案,测试广告仅以纵向显示,而实际广告将在两种方向上显示。