Landscape/Rotating AdWhirlView not displaying ads properly

126 views
Skip to first unread message

Th3Highwaym0n

unread,
Feb 23, 2010, 12:34:29 PM2/23/10
to AdWhirl Users
I am developing an application that remains in landscape mode the
entire time. I need the AdWhirlView to also display in landscape mode.
However, I've tried some methods and none of them seem to work.

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.

Th3Highwaym0n

unread,
Feb 23, 2010, 4:29:32 PM2/23/10
to AdWhirl Users
An update on this. I've figured out how to successfully rotate the
AdWhirlView, have the ad display correctly, and have the view accept
input correctly.

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.

Nigel Choi

unread,
Feb 23, 2010, 5:48:08 PM2/23/10
to adwhir...@googlegroups.com
I'm working to update the sample code to test landscape mode, and so far I haven't have a need to use CGAffineTransform. Did you try changing shouldAutoRotateToInterfaceOrientation in your view controller?

You can simply center the AdWhirlView instance in the landscape screen.

Nigel.

Nigel Choi

unread,
Feb 24, 2010, 5:51:37 PM2/24/10
to adwhir...@googlegroups.com
Th3Highwaym0n,

I'm still trying to understand the need for doing the transformation yourself. Please let me know if I'm missing something.

If you are developing a landscape-only app, you can force the device to be in landscape mode only by adding a key in your Info.plist file:

<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>

And making sure that shouldAutoRotateToInterfaceOrientation returns YES only for UIInterfaceOrientationLandscapeRight . That way, you don't have to do the transformation yourself. The UIKit framework/the OS will do it for you, and you'll be working on a coordinate system the right side up, with the dimension 480 along x and 320 along y .

Th3Highwaym0n

unread,
Mar 1, 2010, 4:17:11 PM3/1/10
to AdWhirl Users
I have the force landscape in the Info.plist file.

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.

Nigel Choi

unread,
Mar 2, 2010, 1:38:24 AM3/2/10
to adwhir...@googlegroups.com
The latest code at http://code.google.com/p/adwhirl/source/list?repo=sdk has landscape mode enabled in the sample project. You can check it out using hg. Set up the ad networks and set "Initial Interface Orientation" (UIInterfaceOrientation) to "Landscape (right home button)" UIInterfaceOrientationLandscapeRight in the AdWhirlSDK2_Sample-Info.plist file. The iPhone Simulator starts rotated with the home button on the right.

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.

Reply all
Reply to author
Forward
0 new messages