почему addview не вписывается в ширину - PullRequest
0 голосов
/ 28 февраля 2012

Я хочу отобразить 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

любая идея, как это решить enter image description here С наилучшими пожеланиями

Ответы [ 2 ]

2 голосов
/ 28 февраля 2012

Я обновил код.

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 голос
/ 28 февраля 2012

Это совсем не работает на iPhone, потому что весь код размещения, который у вас есть, есть для iPad только потому, что код находится внутри блока if.

А что касается заполнения ширины, так какВы не сказали, что появляется.

...