0

ユーザーが iPad を portate ではなく横向きモードにしたときに、高さのサイズを変更する方法を知りたい

このコードはポートレートで機能しますが、ランドスケープでも正しく機能させるにはどうすればよいですか。Google 検索や他のブログを試しましたが、すべて失敗しました。

- (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];
}
4

1 に答える 1

0

これを試して、

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        //your frame for landscape
    } else {
        //your frame for portrait
    } 
}
于 2012-09-10T04:54:25.137 に答える