0

我想在屏幕底部显示 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 中的宽度

任何想法如何解决 在此处输入图像描述 最好的问候

4

2 回答 2

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)]; 


            }

        }
于 2012-02-28T17:38:23.923 回答
1

它在 iPhone 上根本不起作用,因为您拥有的所有放置代码仅适用于 iPad,因为代码在 if 块内。

至于填充宽度,因为你还没有说出现了什么。

于 2012-02-28T16:37:31.810 回答