2012-06-17 5 views
3

나는 장치의 방향에 따라 내 uiviews에 문제가 있어요는 ...처리 IOS 장치 방향

나는 데 가장 큰 문제는

UIDeviceOrientationFaceUp 
UIDeviceOrientationFaceDown 

가 난 단지 원하는 내보기로 장난하는 것입니다 세로 및 가로 방향 (왼쪽 오른쪽)을 지원하므로 장치 방향이 바뀌면 내보기가 올바르게 변경됩니다 ..

이것은 내가 지금 구현 한 것입니다. 기본적으로 화면의 맨 아래에서 위로 스크롤하고이보기에 사용자가 다른보기를로드하도록 선택할 수있는 몇 가지 단추가있는 UIView입니다. 다음 아이콘 6,6,4입니다 풍경 경우

#pragma jumpBarButtons 
- (void)jumpBarButtonPosition 
{ 

    //orientation stuff 
    if (jumpBar.isViewLoaded) { 

     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 


     switch (orientation) { 
      case UIDeviceOrientationPortrait: 
      { 
       NSLog(@"Portrait"); 

       // Row one 
       jumpButton1.frame = CGRectMake(18.45, 23.0, 57.0, 57.0); 
       jumpButton2.frame = CGRectMake(93.9, 23.0, 57.0, 57.0); 
       jumpButton3.frame = CGRectMake(169.35, 23.0, 57.0, 57.0); 
       jumpButton4.frame = CGRectMake(244.8, 23.0, 57.0, 57.0); 
       // Row tow 
       jumpButton5.frame = CGRectMake(18.45, 95.0, 57.0, 57.0); 
       jumpButton6.frame = CGRectMake(93.9, 95.0, 57.0, 57.0); 
       jumpButton7.frame = CGRectMake(169.35, 95.0, 57.0, 57.0); 
       jumpButton8.frame = CGRectMake(244.8, 95.0, 57.0, 57.0); 
       // Row three 
       jumpButton9.frame = CGRectMake(18.45, 167.0, 57.0, 57.0); 
       jumpButton10.frame = CGRectMake(93.9, 167.0, 57.0, 57.0); 
       jumpButton11.frame = CGRectMake(169.35, 167.0, 57.0, 57.0); 
       jumpButton12.frame = CGRectMake(244.8, 167.0, 57.0, 57.0); 
       // Row four 
       jumpButton13.frame = CGRectMake(18.45, 239.0, 57.0, 57.0); 
       jumpButton14.frame = CGRectMake(93.9, 239.0, 57.0, 57.0); 
       jumpButton15.frame = CGRectMake(169.35, 239.0, 57.0, 57.0); 
       jumpButton16.frame = CGRectMake(244.8, 239.0, 57.0, 57.0); 
      } 
       break; 

case UIDeviceOrientationLandscapeLeft: 
      case UIDeviceOrientationLandscapeRight: 
      { 
       viewSpaceHeight = 207; 
       viewSpaceWidth = 480; 

       // Row one 
       jumpButton1.frame = CGRectMake(19.7, 9.0, 57.0, 57.0); 
       jumpButton2.frame = CGRectMake(96.42, 9.0, 57.0, 57.0); 
       jumpButton3.frame = CGRectMake(173.13, 9.0, 57.0, 57.0); 
       jumpButton4.frame = CGRectMake(249.84, 9.0, 57.0, 57.0); 
       jumpButton5.frame = CGRectMake(326.55, 9.0, 57.0, 57.0); 
       jumpButton6.frame = CGRectMake(403.26, 9.0, 57.0, 57.0); 
       // Row tow 
       jumpButton7.frame = CGRectMake(19.7, 75.0, 57.0, 57.0); 
       jumpButton8.frame = CGRectMake(96.42, 75.0, 57.0, 57.0); 
       jumpButton9.frame = CGRectMake(173.13, 75.0, 57.0, 57.0); 
       jumpButton10.frame = CGRectMake(249.84, 75.0, 57.0, 57.0); 
       jumpButton11.frame = CGRectMake(326.55, 75.0, 57.0, 57.0); 
       jumpButton12.frame = CGRectMake(403.26, 75.0, 57.0, 57.0); 
       // Row three 
       jumpButton13.frame = CGRectMake(19.7, 141.0, 57.0, 57.0); 
       jumpButton14.frame = CGRectMake(96.42, 141.0, 57.0, 57.0); 
       jumpButton15.frame = CGRectMake(173.13, 141.0, 57.0, 57.0); 
       jumpButton16.frame = CGRectMake(249.84, 141.0, 57.0, 57.0); 

      } 
       break; 
//.. 

그게 전부는 거의 그것을 세로, 16 개 4,4,4,4 아이콘이있는 경우. 장치가 앞면이 보이거나 뒤집힌 경우 어떻게됩니까? 이러한 단추보기가 모두 사라집니다.이 작업을 중단하려면 어떻게해야합니까? 어떤 도움도 감사하겠습니다.

답변

3

대신 UIInterfaceDirection을 사용하십시오. 완벽한 아

[[UIApplication sharedApplication] statusBarOrientation] 
+0

: 그것 UIApplication 클래스의 부분은 쉽게 다음과 같이 현재의 방향을 확인할 수 있습니다 만 다음 값

typedef enum { UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft } UIInterfaceOrientation; 

을 포함하고 있습니다! 고마워요. .. 나는 잠시 미쳐 가고 있었지만! :피 – HurkNburkS