2011-12-18 31 views
0

我在iOS4.3上測試通用應用程序(iPhone/iPad)。它有一個iAd,我想在兩個方向的屏幕底部定位.. 下面是代碼;在屏幕底部定位iAd(兩個方向)

- (void) viewWillAppear:(BOOL)animated { 
adView_.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]; 
    adView_.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 

    CGRect adFrame = adView_.frame; 
    adFrame.origin.y = self.view.frame.size.height-adView_.frame.size.height; 
    adView_.frame = adFrame; 

    adView_.delegate = self; 
    [webView addSubview:adView_]; 
    [self.view bringSubviewToFront:adView_]; 
    self.bannerIsVisible=NO; 

    [super viewWillAppear: animated]; 
} 

現在爲了處理異化,我有;

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) 
     self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape; 
    else 
     self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 
    CGRect adFrame = adView_.frame; 
    adFrame.origin.y = self.view.frame.size.height-adView_.frame.size.height; 
    adView_.frame = adFrame; 
    [webView addSubview:adView_]; 
    [self.view bringSubviewToFront:adView_]; 
    self.bannerIsVisible=NO; 
} 

我的問題是關於應用程序的負載(縱向),我能看到清晰的iAd位於屏幕底部。

但是,只要將方向改爲橫向,我就看不到iAd。我看到了這個信息;

ADBannerView:警告甲橫幅視圖(0x62534a0)具有一個廣告,也可以是 遮蔽。此消息僅在每個橫幅視圖中打印一次。

我想我做錯了什麼內部willRotateToInterfaceOrientation

請幫我解決這個問題。 謝謝。

回答

1

嘗試將代碼移動到didRotateFromInterfaceOrientation。新的幾何圖形尚未在willRotateToInterfaceOrientation中設置。

+0

Thx很多...這個更新並沒有解決問題..請建議替代方式.. – testndtv 2011-12-18 18:36:30

+0

結果是相同的要麼使用willRotateToInterfaceOrientation或didRotateFromInterfaceOrientation ...那些內部的實際代碼是否需要有所改變? – testndtv 2011-12-19 04:16:07