Hello,
I am trying to get my iAds to autorotate, so far without success. My code appears below. Is there anything missing that I would need for autorotation? The portrait orientation displays fine, but the landscape ad disappears from the screen. Thanks!
My .h:
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface AutorotateViewController : UIViewController {
IBOutlet ADBannerView *myAd;
}
@property (nonatomic, retain) ADBannerView *myAd;
@end
My .m:
#import "AutorotateViewController.h"
@implementation AutorotateViewController
@synthesize myAd;
- (void)dealloc {
myAd.delegate = nil;
[myAd release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.myAd.requiredContentSizeIdentifiers = [NSSet setWithObjects:
ADBannerContentSizeIdentifier320x50,
ADBannerContentSizeIdentifier480x32,
nil];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
if (UIInterfaceOrientationIsPortrait(orientation)) {
myAd.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
}
else
{
myAd.currentContentSizeIdentifier = ADBannerContentSizeIdentifier480x32;
}
}
@end