我想在屏幕底部显示addview,我的应用是通用的,所以我在viewdidload中使用此代码
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)
{
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 80.0f, 320.0f, 40)];
}
else
{
NSLog(@"///////////////////////////// I'm here /////////////////////");
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 80.0f, 1024 , 40)];
}
}
else
{
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)
{
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 40.0f, 320.0f, 40)];
}
else
{
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 40.0f, 1024 , 40)];
}
}
[adView setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin];
//adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview: adView];
[self.view bringSubviewToFront:adView];
问题是视图永远不能在iphone中工作而不能很好地填充ipad中的宽度
任何想法如何解决这个问题 最好的问候
答案 0 :(得分:2)
我更新了代码。
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)
{
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 80.0f, 768.0f, 40)];
}
else
{
NSLog(@"///////////////////////////// I'm here /////////////////////");
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 80.0f, 1024 , 40)];
}
}
else
{
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)
{
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 40.0f, 320.0f, 40)];
}
else
{
adView= [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 40.0f, 480 , 40)];
}
}
答案 1 :(得分:1)
它在iPhone上根本不起作用,因为你所拥有的所有放置代码仅适用于iPad,因为代码在if块内。
至于填充宽度,因为你还没有说出现的是什么。