xcode requiredContentSizeIdentifiers 已弃用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15512459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
requiredContentSizeIdentifiers is deprecated
提问by user2167312
my code is
我的代码是
-(void)viewDidLoad
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier =ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
adView.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];
}
//when banner is loaded successfully
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
//when any problems occured
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
The code
编码
currentContentSizeIdentifier
requiredContentSizeIdentifiers
ADBannerContentSizeIdentifierPortrait
is deprecated, so what do I replace it with, so it will still work?
已弃用,所以我用什么替换它,这样它仍然可以工作?
I need to do this before I submit it, because if I don't, the app will get rejected.
我需要在提交之前执行此操作,因为如果我不这样做,该应用程序将被拒绝。
Please help me
请帮我
Thanks in Advance
提前致谢
回答by JeffN
If you remove the offending lines of code and implement the one below, it will achieve the same result but it is not deprecated.
如果您删除有问题的代码行并实现以下代码行,它将获得相同的结果,但不会被弃用。
Remove:
消除:
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier =ADBannerContentSizeIdentifierPortrait;
Add:
添加:
[adView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
回答by Vandana Rao
iOS 6 comes with many new updates. There are so many autoresize controls are deprecated. ADBannerContentSizeIdentifierPortrait
is also deprecated.
iOS 6 带来了许多新的更新。不推荐使用太多自动调整大小控件。ADBannerContentSizeIdentifierPortrait
也已弃用。
Here is link which will help you to solve this issue.
这是可以帮助您解决此问题的链接。