我创建了一个只能在横向模式下运行的应用。我正在尝试制作它,以便添加将在横向屏幕上延伸。最近的问题表明
[self.bannerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
应该给我预期的效果,但事实并非如此。我以编程方式创建横幅。我的横幅的代码是
//allocate add banner
self.bannerView = [[ADBannerView alloc]initWithAdType:ADAdTypeBanner];
[self.bannerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
//_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
/*CGRect contentFrame = self.view.bounds;
CGRect bannerFrame = _bannerView.frame;
contentFrame.size.height -= _bannerView.frame.size.height;
bannerFrame.origin.y = contentFrame.size.height;
self.bannerView.frame = bannerFrame;*/
[self.view addSubview:self.bannerView];
所有委托方法都包含在项目的后面。
答案 0 :(得分:0)
我设法通过强制iAD成为视图的宽度来修复它
//allocate add banner
self.bannerView = [[ADBannerView alloc]initWithAdType:ADAdTypeBanner];
[self.bannerView setAlpha:0];
[self.bannerView setDelegate:self];
//_bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
[self.bannerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
CGRect contentFrame = self.view.bounds;
CGRect bannerFrame = _bannerView.frame;
bannerFrame.size.width = contentFrame.size.width;
self.bannerView.frame = bannerFrame;
bannerFrame = _bannerView.frame;
contentFrame.size.height -= _bannerView.frame.size.height;
bannerFrame.origin.y = contentFrame.size.height;
self.bannerView.frame = bannerFrame;
[self.view addSubview:self.bannerView];
答案 1 :(得分:0)
如果将width属性设置为屏幕宽度,则创建对象时它将起作用。例如:
iAds_View = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 0, screen_Width, iAds_View.frame.size.height)];