0

I want to display addview to the bottom of my screen, my app is universal so I use this code in 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];

the problem is that the view never work in iphone and not work well fill the width in ipad

any idea how to solve that enter image description here Best regards

AMH
  • 6,363
  • 27
  • 84
  • 135

2 Answers2

2

I updated the code.

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


            }

        }
Apurv
  • 17,116
  • 8
  • 51
  • 67
  • ur code work well but not in the landscape of ipad as u can see in my updated image – AMH Feb 28 '12 at 19:07
  • When you are changing the orientation, u will have to adjust frame accordingly. Above code will create the view based on initial orientation. – Apurv Feb 29 '12 at 04:08
  • this view appear in without change thee orientation – AMH Feb 29 '12 at 08:23
1

It doesn't work at all on the iPhone, because all the placement code you have there is for the iPad only because the code is within that if block.

And as for filling the width, since you haven't said what is appearing.

Abizern
  • 146,289
  • 39
  • 203
  • 257