Reputation: 1299
Im trying to rotate the AdWhirl bannerview. The only documentation AdWhirl provides is:
6.2 Device Orientation Some ad networks including iAd will vary their ad dimensions with device orientation. If your app supports rotation you must forward orientation changes to AdWhirlView by invoking AdWhirlView.rotateToOrientation: within your UIViewController’s should/willAutorotateToInterfaceOrientation: implementation and then refit as per 6.1. If your app’s notion of orientation somehow differs from UIDevice.orientation you must also implement AdWhirlDelegate.adWhirlCurrentOrientation to return the appropriate value.
I'm trying to figure this out and so far correctly implemented the adWhirlDidReceiveAd method but I can't correctly rotate and/or resize the ad in question.
Upvotes: 0
Views: 707
Reputation: 11
[AdWhirlView rotateToOrientation] calls rotateToOrientation
method for each current network adapter.
However, some network adapter does't override this method. Default implementation of this method does nothing.
So, you need to override rotateToOrientation method.
Next is a sample implementation for network adapter for AdMob.
AdWhirlAdapterGoogleAdMobAds.m
-(void)rotateToOrientation:(UIInterfaceOrientation)orientation {
GADBannerView* adMobView;
adMobView = (GADBannerView*)adNetworkView;
switch (orientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
adMobView.adSize = kGADAdSizeSmartBannerPortrait;
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
adMobView.adSize = kGADAdSizeSmartBannerLandscape;
break;
default:
break;
}
}
Upvotes: 1
Reputation: 1685
Set AdWhirl at the bottom of the view: here
Make the ad static when scrolling (i.e. TableView): here
This is how I rotate ads with AdWhirl (probably not the best solution...):
awView.transform = CGAffineTransformIdentity;
awView.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
awView.bounds = CGRectMake(0.0, 0.0, 480, 320);
You'll need to change the coordinates depending on your view.
Upvotes: 1
Reputation: 8931
In your UIViewController implementation, add the shouldAutorotateToInterfaceOrientation: like so:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation is supported)
{
[adWhirlView_ rotateToOrientation:interfaceOrientation];
return YES;
}
else
{
return NO;
}
}
Note that as long as shouldAutorotateToInterfaceOrientation: is implemented, the AdWhirlView will rotate with the rest of the layout. However, calling rotateToOrientation: will tell the AdWhirlView to forward an orientation change signal to the ad so that an individual ad network can optimize the ad for landscape if it chooses.
Upvotes: 0