我想知道当用户将 ipad 置于横向模式而不是 portate 时如何调整高度
这段代码适用于肖像,但我需要做些什么才能让它在风景中也能正常工作。我试过谷歌搜索和其他博客,但所有尝试都失败了。
- (void) viewDidLoad
{
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
CGFloat screenXPos = (screenWidth /2);
CGFloat screenYPos = screenHeight - 60;
[bannerView_ setCenter:CGPointMake(screenXPos, screenYPos)];
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
[bannerView_ loadRequest:request];
[super viewDidLoad];
}