Question

I have created an iOS6 "Single View" iPhone application.

The application is portrait only.

I added iAds to the application.

I add additional views to the application like this:

         if (self.menuChoiceInstance == nil) {            
                 self.menuChoiceInstance = [[NJDViewControllerMenuChoice alloc] initWithNibName:@"NJDViewControllerMenuChoice" bundle:nil];
                 self.menuChoiceInstance.delegate = self;
         }

         [self.view addSubview:self.menuChoiceInstance.view];

Everything seemed to work fine.

I then added universal/iPad support. Including the following line when I add my subview:

         [self.menuChoiceInstance.view setFrame:CGRectMake(0, 0, self.view.frame.size.width,
                                   self.view.frame.size.height)];

Now I get issues with iAds.

When pressing an iAd on the the rootViewController the iPad rotates to landscape. It then rotates back to portrait on closing the advert.

However pressing an iAd on the iPad on a subview makes the view rotate to landscape, and it stays landscape on closing. This destroys my user interface.

This iPad issue is the main problem, but I now also occasionally see issues with the iPhone view too, which could be related.

The iAd banner at the bottom of the screen showing the test ads sometimes has giant text and icons within it, making them overlap each other and impossible to read. Pressing the iAd rotates the phone to landscape (again in a portrait only app), yet the iAd shows the advert as if it is still portrait, with stretched content that goes off the bottom of the screen.

Was it helpful?

Solution 2

I believe the issue was caused by the fact that I was adding subviews onto my current view, rather than switching views.

I have changed the code that adds a subview from:

[self.view addSubview:self.statsInstance.view];

to code that presents a view.

[self presentViewController: self.settingsInstance animated:YES completion:nil];

This seems to have resolved my issue, as well as some other issues with iAd delegation methods (bannerViewActionDidFinish was called straight after the ad loaded.)

OTHER TIPS

Similar issue here. Hard to find out what was it because i used a third party API. My problem was solved by adding my UIView as child to the rootViewController. Then my view begin to respond all main window changes. Just a line like this somewhere along viewDidLoad of myUIViewController (or as many as you have).

[myUIWindow.rootViewController addChildViewController:self];

Similar issues...

iAd Landscape Strange View Behavior

Force ADBannerView to rotate (Not "orientation" but actual transform)

iAd banner rotates my view to landscape

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top