2012-02-28 1 views
0

폭에 맞지 않는, 내 응용 프로그램이 내가있는 viewDidLoad에서이 코드를 사용 보편적가 왜 addview가 내 화면 하단에 addview 표시 할

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

문제는 뷰 결코 아이폰에서 작동하고 잘 작동 아이 패드의 폭을 기입하지

모든 배치 코드는 t을 가지고 있기 때문에 enter image description here 안부

답변

1

그것은, 아이폰에 전혀 작동하지 않는 것을 해결하는 방법을 어떤 생각 이 코드는 블록 내에있을 때만 iPad 용입니다.

폭을 채우는 것에 대해, 당신은 무엇이 나타나는지 말하지 않았기 때문에.

+0

확실히 ipad는 너비가 768 또는 1024 여야합니다. – ader

+0

내 질문을 업데이 트하고 Apurv에 따라 사진 – AMH

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


      } 

     } 
+0

UR 코드가 잘 작동하지만 ipad의 풍경에 u가 업데이트 된 이미지에서 볼 수 있습니다. – AMH

+0

방향을 변경하면 u가 이에 따라 프레임을 조정해야합니다. 위의 코드는 초기 방향에 따라 뷰를 생성합니다. – Apurv

+0

이보기는 변경되지 않고 나타납니다. – AMH

관련 문제