2011-12-25 6 views
1

(長いポストの私の謝罪)私のAQGridViewをジャズアップするには、添付されたコードが選択されたセルをUIViewにコピーし、そのビューをアニメーション化して画面を満たし、ビュー変換をフルスクリーンのカバーアニメーションのように見せます。自由に再利用することができますが、それは私の問題ではありません。私の問題はランドスケープのアニメーションです。これは違うはずです。私は自分のセルビューを画面の右半分に動かし、画面の右半分を塗りつぶして(すでに完成しています)、次に画面の向こう側をyフリップローテーションさせたいと思います。 CGPointMake(0.5、0.5)のアンカーポイント。動作しませんし、xの値を画面の半分に戻してもう一度戻しても、それは単に実行して画面から飛びます!助けて!!UIViewのアニメーションとUIViewの反転で楽しむ

EDIT:(コードは、今私はそれを取ったすべてのことをレンダリングし、何の翻訳は必要ありません、それを反転した、self.navigationController.viewプロパティに新しいUIView'sを追加していたことを実現していないのおかげで作業している!) WORKING CODE :

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) { 
      self.view.userInteractionEnabled = NO; 

      [self.navigationController.view addSubview:viewForCopy]; 
      [self.navigationController.view bringSubviewToFront:viewForCopy]; 
      [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]; 
      [viewForCopy setAlpha:1.0f]; 

      [[_gridView cellForItemAtIndex:index] setAlpha:0.0f]; 

      [UIView animateWithDuration:1.5f 
            delay:0.0f 
           options:UIViewAnimationCurveEaseInOut 
          animations:^{ 
           [self.navigationController.navigationBar setAlpha:0.0f]; 
           [newShadow removeFromSuperlayer]; 
           [viewForCopy setFrame:CGRectMake(-158, 10, self.view.bounds.size.width * 1.55, self.view.bounds.size.height * 1.25)]; 
           [self.navigationController.navigationBar setAlpha:0.0f]; 
          } 
          completion:^(BOOL finished) { 
           [UIView animateWithDuration:2.0f 
                 delay:0.0f 
                options:UIViewAnimationCurveEaseInOut 
                animations:^{ 
                 [viewForCopy setAlpha:0.0f]; 
                 CATransform3D _3Dt = CATransform3DIdentity; 
                 _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width * -1, 0, 0); 
                 _3Dt = CATransform3DRotate(_3Dt, M_PI/-2.0f, 0.0f, 0.1f, 0.0f); 
                 _3Dt.m34 = 1.0f/500.0f; 
                 _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width, 0, 0); 
                 viewForCopy.layer.transform = _3Dt; 
                 [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES]; 
                 [self.navigationController pushViewController:viewController animated:NO]; 

                } 
                completion:^(BOOL finished) { 
                }]; 
           [[_gridView cellForItemAtIndex:index] setAlpha:1.0f]; 
           [self.navigationController.view sendSubviewToBack:viewForCopy]; 

          }]; 
     } 
      else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){ 
       UIView *viewforCopyLandscape2 = [[[UIView alloc]initWithFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]autorelease]; 
       viewforCopyLandscape2.backgroundColor = [UIColor whiteColor]; 
       viewforCopyLandscape2.alpha = 0.0f; 

       [self.navigationController.view addSubview:viewforCopyLandscape2]; 
       [self.navigationController.view bringSubviewToFront:viewforCopyLandscape2]; 
       [self.navigationController.view addSubview:viewForCopy]; 
       [self.navigationController.view bringSubviewToFront:viewForCopy]; 

       [newShadow removeFromSuperlayer]; 

       [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]; 

       [[_gridView cellForItemAtIndex:index] setAlpha:0.0f]; 

       self.view.userInteractionEnabled = NO; 

       [UIView animateWithDuration:1.5f 
             delay:0.0f 
            options:UIViewAnimationCurveEaseInOut 
            animations:^{ 
             [viewforCopyLandscape2 setFrame:CGRectMake(0, 20, self.view.bounds.size.width/2, self.view.bounds.size.height)]; 
             [viewForCopy setFrame:CGRectMake(407, 10, self.view.bounds.size.width * .78, self.view.bounds.size.height * 1.25)]; 
             [self.navigationController.navigationBar setAlpha:0.0f]; 
             viewforCopyLandscape2.alpha = 1.0f; 
            } 
            completion:^(BOOL finished) { 

             UIView *viewForCopyLandscape = [[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height)]autorelease]; 
             UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height)); 
             [self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
             UIImageView *viewImage = [[[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]autorelease]; 
             UIGraphicsEndImageContext(); 
             viewForCopyLandscape = viewImage; 
             [self.navigationController.view addSubview:viewForCopyLandscape]; 
             [self.navigationController.view bringSubviewToFront:viewForCopyLandscape]; 

             [viewForCopy setAlpha:0.0f]; 
             [UIView animateWithDuration:2.0f 
                  delay:0.0f 
                  options:UIViewAnimationCurveEaseInOut 
                 animations:^{ 

                  CATransform3D transform = CATransform3DMakeRotation(-M_PI/1.1, 0.0, 1.0, 0.0); 
                  transform.m34 = 1.0f/2500.0f; 
                  viewForCopyLandscape.layer.transform = transform; 

                  [self.navigationController.view sendSubviewToBack:viewForCopy]; 
                  [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES]; 
                  [self.navigationController pushViewController:viewController animated:NO]; 
                  [viewforCopyLandscape2 removeFromSuperview]; 

                 }   
                 completion:^(BOOL finished) { 
                  [[_gridView cellForItemAtIndex:index] setAlpha:1.0f]; 
                  [viewForCopy removeFromSuperview]; 
                  [UIView animateWithDuration:1.00 animations:^ { 
                   [viewForCopyLandscape setAlpha:0.0f]; 

                  }]; 
                 }]; 
            }]; 
} 

答えて

0

コードは今ではそれが取ったすべてのことをレンダリングし、それを反転することでした、私はself.navigationController.viewプロパティに新しいのUIViewのを追加していたことを実現していない私のおかげで作業している、何の変換は必要ありません!)

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) { 
      self.view.userInteractionEnabled = NO; 

      [self.navigationController.view addSubview:viewForCopy]; 
      [self.navigationController.view bringSubviewToFront:viewForCopy]; 
      [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]; 
      [viewForCopy setAlpha:1.0f]; 

      [[_gridView cellForItemAtIndex:index] setAlpha:0.0f]; 

      [UIView animateWithDuration:1.5f 
            delay:0.0f 
           options:UIViewAnimationCurveEaseInOut 
          animations:^{ 
           [self.navigationController.navigationBar setAlpha:0.0f]; 
           [newShadow removeFromSuperlayer]; 
           [viewForCopy setFrame:CGRectMake(-158, 10, self.view.bounds.size.width * 1.55, self.view.bounds.size.height * 1.25)]; 
           [self.navigationController.navigationBar setAlpha:0.0f]; 
          } 
          completion:^(BOOL finished) { 
           [UIView animateWithDuration:2.0f 
                 delay:0.0f 
                options:UIViewAnimationCurveEaseInOut 
                animations:^{ 
                 [viewForCopy setAlpha:0.0f]; 
                 CATransform3D _3Dt = CATransform3DIdentity; 
                 _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width * -1, 0, 0); 
                 _3Dt = CATransform3DRotate(_3Dt, M_PI/-2.0f, 0.0f, 0.1f, 0.0f); 
                 _3Dt.m34 = 1.0f/500.0f; 
                 _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width, 0, 0); 
                 viewForCopy.layer.transform = _3Dt; 
                 [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES]; 
                 [self.navigationController pushViewController:viewController animated:NO]; 

                } 
                completion:^(BOOL finished) { 
                }]; 
           [[_gridView cellForItemAtIndex:index] setAlpha:1.0f]; 
           [self.navigationController.view sendSubviewToBack:viewForCopy]; 

          }]; 
     } 
      else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){ 
       UIView *viewforCopyLandscape2 = [[[UIView alloc]initWithFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]autorelease]; 
       viewforCopyLandscape2.backgroundColor = [UIColor whiteColor]; 
       viewforCopyLandscape2.alpha = 0.0f; 

       [self.navigationController.view addSubview:viewforCopyLandscape2]; 
       [self.navigationController.view bringSubviewToFront:viewforCopyLandscape2]; 
       [self.navigationController.view addSubview:viewForCopy]; 
       [self.navigationController.view bringSubviewToFront:viewForCopy]; 

       [newShadow removeFromSuperlayer]; 

       [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]; 

       [[_gridView cellForItemAtIndex:index] setAlpha:0.0f]; 

       self.view.userInteractionEnabled = NO; 

       [UIView animateWithDuration:1.5f 
             delay:0.0f 
            options:UIViewAnimationCurveEaseInOut 
            animations:^{ 
             [viewforCopyLandscape2 setFrame:CGRectMake(0, 20, self.view.bounds.size.width/2, self.view.bounds.size.height)]; 
             [viewForCopy setFrame:CGRectMake(407, 10, self.view.bounds.size.width * .78, self.view.bounds.size.height * 1.25)]; 
             [self.navigationController.navigationBar setAlpha:0.0f]; 
             viewforCopyLandscape2.alpha = 1.0f; 
            } 
            completion:^(BOOL finished) { 

             UIView *viewForCopyLandscape = [[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height)]autorelease]; 
             UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height)); 
             [self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
             UIImageView *viewImage = [[[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]autorelease]; 
             UIGraphicsEndImageContext(); 
             viewForCopyLandscape = viewImage; 
             [self.navigationController.view addSubview:viewForCopyLandscape]; 
             [self.navigationController.view bringSubviewToFront:viewForCopyLandscape]; 

             [viewForCopy setAlpha:0.0f]; 
             [UIView animateWithDuration:2.0f 
                  delay:0.0f 
                  options:UIViewAnimationCurveEaseInOut 
                 animations:^{ 

                  CATransform3D transform = CATransform3DMakeRotation(-M_PI/1.1, 0.0, 1.0, 0.0); 
                  transform.m34 = 1.0f/2500.0f; 
                  viewForCopyLandscape.layer.transform = transform; 

                  [self.navigationController.view sendSubviewToBack:viewForCopy]; 
                  [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES]; 
                  [self.navigationController pushViewController:viewController animated:NO]; 
                  [viewforCopyLandscape2 removeFromSuperview]; 

                 }   
                 completion:^(BOOL finished) { 
                  [[_gridView cellForItemAtIndex:index] setAlpha:1.0f]; 
                  [viewForCopy removeFromSuperview]; 
                  [UIView animateWithDuration:1.00 animations:^ { 
                   [viewForCopyLandscape setAlpha:0.0f]; 

                  }]; 
                 }]; 
            }]; 
} 
関連する問題