2012-06-21 1 views
4

탭 모음에서 표시되는 아이콘 메뉴를 만들었습니다. 이 메뉴는 세로 또는 가로로 볼 수 있습니다.UIView를 애니메이션화하여 크로스 페이드 효과가 제대로 작동하지 않음

화면의 공간 때문에 나는 초상화로 당신이 4x4 아이콘을 볼 수있게 만들었습니다. 그러나 조경으로 보았을 때 크기 조정으로 인해 잘 작동하지 않았습니다. 그래서 나는 그것을 만들었습니다. 이 때문에 6 행 2와 4 행 1을 볼 수 있습니다. 두 개의 UIView를 만들려고 결정했습니다. 두 개의 뷰 사이에서 장치가 회전 할 때 회전합니다.

즉 세로 방향 현재 및 기기가 회전 된 경우 가로 방향으로로드하고 세로 방향을 언로드합니다.

이 나는 ​​장치 회전에서보기를 변경하기 위해 사용하고있는 코드가,이 완벽하게 잘 작동입니다 (가장 좋은 코드가되지 않을 수도 있지만 내가 할 수있는 최선의)

if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) 
     { 
      if([jumpBarContainerLandscape superview]) 
      { 
      // Device is changing from landscape to protrait change views to fit 
      // load landscape view 
      jumpBarContainerPortrait = [[UIView alloc] initWithFrame:CGRectMake(0.0, (367 - jumpBarHeightPortrait), 320.0, (jumpBarHeightPortrait + 49.0))]; 
      jumpBarContainerPortrait.backgroundColor = [UIColor scrollViewTexturedBackgroundColor]; 
      jumpBarContainerPortrait.alpha = 0.0; 

      // add jumpbar container to view 
      [self.view insertSubview:jumpBarContainerPortrait belowSubview:actionTabBar]; 

      [UIView animateWithDuration:0.2 
            delay:0.0f 
           options:UIViewAnimationCurveEaseIn 
          animations:^{ 

           jumpBarContainerLandscape.alpha = 0.0; 


          } completion:^(BOOL finished) { 
           if (finished) { 


           } 
          }]; 


      [UIView animateWithDuration:0.2 
            delay:0.0f 
           options:UIViewAnimationCurveEaseIn 
          animations:^{ 

           jumpBarContainerPortrait.alpha = 1.0; 


          } completion:^(BOOL finished) { 
           if (finished) { 

            // remove subView for superView 
            [jumpBarContainerLandscape removeFromSuperview]; 
           } 
          }]; 

      } 
     } 
     else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) 
     { 
      if ([jumpBarContainerPortrait superview]) 
      { 
      // Device is changing from portrait to landscape change views to fit 
      // load landscape view 
      jumpBarContainerLandscape = [[UIView alloc] initWithFrame:CGRectMake(0.0, (207 - jumpBarHeightLandscape), 480.0, (jumpBarHeightLandscape + 49.0))]; 
      jumpBarContainerLandscape.backgroundColor = [UIColor scrollViewTexturedBackgroundColor]; 
      jumpBarContainerLandscape.alpha = 0.0; 

      // add jumpbar container to view 
      [self.view insertSubview:jumpBarContainerLandscape belowSubview:actionTabBar]; 


       // fade out 
      [UIView animateWithDuration:0.2 
            delay:0.0f 
           options:UIViewAnimationCurveEaseIn 
          animations:^{ 

           jumpBarContainerPortrait.alpha = 0.0; 


          } completion:^(BOOL finished) { 
           if (finished) { 


           } 
          }]; 

       // fade in 
      [UIView animateWithDuration:0.2 
            delay:0.0f 
           options:UIViewAnimationCurveEaseIn 
          animations:^{ 


           jumpBarContainerLandscape.alpha = 1.0; 


          } completion:^(BOOL finished) { 
           if (finished) { 

            // remove subView for superView 
            [jumpBarContainerPortrait removeFromSuperview]; 
           } 
          }]; 
      } 
     } 

지금 문제 나는 두 UIView 사이의 애니메이션이 매우 못생긴다는 ​​것은 매우 부드럽지 만 바람직하지 않은 애니메이션 등의 두 가지 다른 뷰를 볼 수 있습니다. 두 사람이 크로스 페이드하는 좋은 방법을 생각할 수 있는지 궁금합니다. 그것은 abit 부드럽게 보이 ...

어떤 도움을 주시면 대단히 감사하겠습니다.

는 편집 :

그래서 난 그냥 그러나 내가 한 줄에 오류가 '있는 UIView'에 대한 눈에 띄는 @ 인터페이스가 선택 'jumpBarContainerPortrait'를 선언하지 날이 오류를 제공해야하는 CATransaction를 만들기 위해 노력했다 나는 UIView의 방법 "transitionFromView"를 사용, 나는에 .. 어떤 도움을 주시면 감사하겠습니다

[CATransaction begin]; 
      CATransition *animation = [CATransition animation]; 
      animation.type = kCATransitionFade; 
      animation.duration = 3.50; 

      [self.view insertSubview:jumpBarContainerPortrait belowSubview:actionTabBar]; 

      [[self.view jumpBarContainerPortrait] addAnimation:animation forKey:@"Fade"]; // Error is happening here! 
      [CATransaction commit]; 
+0

대신 'kCATransitionFade' 유형으로'CATransition '을 사용해 보았습니까? – sooper

답변

7

대신 별도의 페이드 아래이 오류 및 애니메이션을 페이드 아웃 라인에 주석을 추가했습니다. 예를 들면 다음과 같습니다.

+0

시원한 덕분에, 이것은 일종의 일입니다. 탭바에서 이상한 일을하고 있습니다. 탭바 뒤에 jumpBarContainerPortrait를 삽입하고 있는데도 전환이 발생한 후에 탭 막대 위에 뷰가 표시됩니다. 지금 밖으로. – HurkNburkS

+1

좋습니다. 그것이 당신을 도운다면 내 대답을 "받아 들여"주십시오. –

+0

그래, 내가 가진 애니메이션이 약간 더 나쁜 결과를 낸다. 왜 그런지 모르겠지만, 내 탭바를 없애 버린다. 그게 이상하다. 멋진 솔루션이지만, 내 애니메이션을 위해 아무 것도하지 않아. 그래서 나는 이 스레드를 열어두면 다른 사람이 제안 사항이 있는지 확인합니다. 그렇다면 내가 올바른 것으로 표시 할 것입니다. – HurkNburkS

관련 문제