Search code examples
iosios5iad

On dismiss view iAds becomes black in ios 5 ipad.(dark black)


I have a tab based application. I have created an iAd object in app delegate class and using it in my three view controller class. It's working good on second tab's screen and third tab's screen. On second tab there is a table view, when clicking the row of that table view i navigate to the new view where i have used the same code for iAd. On clicking the iAd, iAd screen opens in landscape mode and when closing the screen becomes black and log the following.

[ADHostWindowController supportsOrientation:]: message sent to deallocated instance 0x100bc740

I created the object in app delegate like this:

self.bannerView = [[ADBannerView alloc]init];
[self.bannerView setDelegate:self];

I'm adding banner in view controllers like this:

[[[self appdelegate] bannerView] setFrame:CGRectMake(0, hightofView-180, 768, 66)]

All my view controllers are in portrait but iAds always open in landscape mode. This is working in iOs 6, but not with iOS 5 on iPad. How do I fix this?


Solution

  • My guess your problem is not related to iAds but rather to memory issues. It seems that an object of class kind ADHostWindowController is being deallocated prematurely.

    My advice would be to make sure that ADHostWindowController is not released i.e (retainCount>=1) before supportsOrientation: is called to it. (which is definitely after the iAd opens).

    For diagnosis: Try logging the retain count of that ADHostWindowController (then maybe retaining it one more time) before opening an iAd and see what happens.