When I apply a CGAffineTransform to rotate the view the ad either
doesn't display or doesn't display correctly. I tested this by setting
the background color of the view to something noticeable and I can see
it rotated correctly on the screen.
I subclassed a UIViewController and made it so the only supported
orientation was landscape. The ads still show up in portrait mode.
I'm completely stumped and would really appreciate any help.
In the initWithDelegate function of AdWhirlView.m I apply the
transformation to rotate the view 90 degrees into landscape mode.
CGAffineTransform landscapeTransform =
CGAffineTransformMakeRotation(0.0174532925*90);
self.transform = landscapeTransform;
This will rotate the view but not the content inside of it. This
occurs at another spot in the code listed below.
In the helperFitAdNetworkView function of AdWhirlAdNetworkAdapter
+Helpers.m I swap the width and height to fit the new view.
frame.size.width = adWhirlView.frame.size.height;
frame.size.height = adWhirlView.frame.size.width;
In my own code I've added a flag so I can easily switch between
landscape/portrait mode for the ads. I propose that this be added and
included in some kind of documentation because this took me WAY too
long to figure out.
When you want to move the UIView you have to use the requested ad
view's existing transform or else the 90 degree rotation will be lost.
AdWhirlView* adView = [AdWhirlView
requestAdWhirlViewWithDelegate:self];
CGAffineTransform newTransform =
CGAffineTransformTranslate(adView.transform, x, y);
adView.transform = newTransform;
Hope this helps people who are trying to use AdWhirl in landscape mode
and that this is added in a future update.
You can simply center the AdWhirlView instance in the landscape screen.
Nigel.
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
I have also subclassed a UIViewController, overrode the
shouldAutoRotateToInterfaceOrientation function to return YES for
UIInterfaceOrientationLandscapeRight and added the AdWhirlView to the
UIViewController's view. It didn't auto-rotate for me. I'm not sure if
I was doing anything incorrectly, but I managed to get it to work
using a transformation.
Check it out and let us know how you differ. Perhaps you have a different approach in getting landscape to work, but we got it working without having to do manual transformations. What ad networks are you using?
Nigel.