这是我的 iAd 代码,我收到了关于
setRequiredContentSizeIdentifiers - deprecated in iOS 6
ADBannerContentSizeIdentifier320x50 - deprecated in iOS 4.2
ADBannerContentSizeIdentifier480x32 - deprecated in iOS 4.2
setCurrentContentSizeIdentifier - deprecated in iOS 6
ADBannerContentSizeIdentifier480x32 - deprecated in iOS 4.2
我该如何解决这个问题,所以没有警告。
- (int)getBannerHeight:(UIDeviceOrientation)orientation
{
if (UIInterfaceOrientationIsLandscape(orientation)) {
return 32;
} else {
return 50;
}
}
- (int)getBannerHeight
{
return [self getBannerHeight:[UIDevice currentDevice].orientation];
}
- (void)createAdBannerView
{
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil) {
self->adView = [[classAdBannerView alloc]
initWithFrame:CGRectZero];
[adView setRequiredContentSizeIdentifiers:[NSSet setWithObjects:
ADBannerContentSizeIdentifier320x50,
ADBannerContentSizeIdentifier480x32, nil]];
if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
[adView setCurrentContentSizeIdentifier:
ADBannerContentSizeIdentifier480x32];
} else {
[adView setCurrentContentSizeIdentifier:
ADBannerContentSizeIdentifier320x50];
}
[adView setFrame:CGRectOffset([adView frame], 0,
-[self getBannerHeight])];
[adView setDelegate:self];
[self.view addSubview:adView];
}
}
- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation
{
if (adView != nil) {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
[adView setCurrentContentSizeIdentifier:
ADBannerContentSizeIdentifier480x32];
} else {
[adView setCurrentContentSizeIdentifier:
ADBannerContentSizeIdentifier320x50];
}
[UIView beginAnimations:@"fixupViews" context:nil];
if (bannerIsVisible) {
CGRect adBannerViewFrame = [adView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = 0;
[adView setFrame:adBannerViewFrame];
CGRect contentViewFrame = _contentView.frame;
contentViewFrame.origin.y =
[self getBannerHeight:toInterfaceOrientation];
contentViewFrame.size.height = self.view.frame.size.height -
[self getBannerHeight:toInterfaceOrientation];
_contentView.frame = contentViewFrame;
} else {
CGRect adBannerViewFrame = [adView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y =
-[self getBannerHeight:toInterfaceOrientation];
[adView setFrame:adBannerViewFrame];
CGRect contentViewFrame = _contentView.frame;
contentViewFrame.origin.y = 0;
contentViewFrame.size.height = self.view.frame.size.height;
_contentView.frame = contentViewFrame;
}
[UIView commitAnimations];
}
}