2012-06-13 9 views
4

내 앱에서 scrollview가 있고 두 번째로 scrollview의 마지막 페이지로 스크롤합니다. tableviewcontroller에 연결됩니다.segue 동안 회전이 깨졌습니다.

- (void) perform { 
    UIViewController *src = (UIViewController *) self.sourceViewController; 
    UIViewController *dst = (UIViewController *) self.destinationViewController; 

    src.view.transform = CGAffineTransformMakeTranslation(0, 0); 
    dst.view.transform = CGAffineTransformMakeTranslation(320, 0); 

    [UIView animateWithDuration:0.3 
        animations:^{ 
         [src presentModalViewController:dst animated:NO]; 
         src.view.transform = CGAffineTransformMakeTranslation(320, 0); 
         dst.view.transform = CGAffineTransformMakeTranslation(0, 0); 
        } 
    ]; 
} 

그리고 사용자가 UIInterfaceOrientationPortrait에있을 때 그것은 마법처럼 작동합니다

하지만 UIStoryboardSegue 클래스를 확장 및 구현의 tableview 컨트롤러에있는 ScrollView에서 점프 할 때 "애니메이션 같은 페이징"을 달성하기 위해

이 같은 방법을 수행 정위. 하지만 UIInterfaceOrientationLandscapeLeft 또는 Right로 전환하면 제대로 작동하지 않습니다.

내가 기본적으로 여기 을하고 싶은 것은 tableviewcontroller이 (하지가 기본 동작입니다으로 상단 또는 하단에서) 메인 화면에 왼쪽에서 오는 것 같습니다 그래서 위의 코드처럼을 SEGUE을 수행하는 것입니다 정상적인 방향으로 작동합니다. 나는 다음과 같은 해결책을 상상해 보았다.

- (void) perform { 
    UIViewController *src = (UIViewController *) self.sourceViewController; 
    UIViewController *dst = (UIViewController *) self.destinationViewController; 


    if ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight){ 

    }else{ 
    src.view.transform = CGAffineTransformMakeTranslation(0, 0); 
    dst.view.transform = CGAffineTransformMakeTranslation(320, 0); 
    } 
    [UIView animateWithDuration:0.3 
        animations:^{ 
         [src presentModalViewController:dst animated:NO]; 
         if ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight){ 
         }else{ 
         src.view.transform = CGAffineTransformMakeTranslation(320, 0); 
         dst.view.transform = CGAffineTransformMakeTranslation(0, 0); 
         } 
        } 
    ]; 
} 

그러나 나는 어떤 도움이 주어지기가 더 어렵다.

질문 업데이트 :

내가 지금이 시도 :

- (void) perform { 
    UIViewController *src = (UIViewController *) self.sourceViewController; 
    UIViewController *dst = (UIViewController *) self.destinationViewController; 

    [UIView transitionWithView:src.navigationController.view duration:0.3 
         options:UIViewAnimationTransitionFlipFromRight 
        animations:^{ 
         [src.navigationController pushViewController:dst animated:YES]; 
        } 
    completion:NULL]; 
} 

나는 다음과 같은 얻을 오류 :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported' 

답변

2
  1. 보다는 이제까지 하드 폭 (320)을 코딩, 당신 항상 런타임에 결정해야합니다. src.view.frame.size.width.

  2. 내 장치에서 세로보기가 괜찮 았기 때문에 놀랐습니다. 이전보기가 깜박입니다.

  3. 새로운 시도처럼 보이는 것이 매우 다릅니다 (밀기와 반대로 뒤집기). 어떤 효과가 있습니까? 당신이 플립하려면

, 당신은 같은 일을 할 수있는 :

[UIView animateWithDuration:0.5 
       animations:^{ 
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
        [sourceViewController.navigationController.view addSubview:destinationViewController.view]; 
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:sourceViewController.navigationController.view cache:NO]; 
       } 
       completion:^(BOOL finished){ 
        [destinationViewController.view removeFromSuperview]; 
        [sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; 
       }]; 

당신이, 내가 일반적으로 단지 예를 들어, 당신이 좋아하는 뭔가를 할 수, 프레임/센터 변경 푸시을 더 원하는 경우 :

float width = sourceViewController.navigationController.view.frame.size.width; 

CGPoint right = destinationViewController.view.center; 
right.x += width; 
destinationViewController.view.center = right; 

[sourceViewController.navigationController.view addSubview:destinationViewController.view]; 

[UIView animateWithDuration:0.5 
       animations:^{ 
        CGPoint left = sourceViewController.navigationController.view.center; 
        left.x -= width; 
        sourceViewController.navigationController.view.center = left; 
       } 
       completion:^(BOOL finished){ 
        [destinationViewController.view removeFromSuperview]; 
        [sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; 
       } 
]; 
+0

두 번째 부분은 나에게 좋았습니다. 새로운보기 컨트롤러의 오른쪽에서 뒤집은 것과 같습니다. – London