2013-08-09 2 views
1

맞춤보기를 사용하여 두 개의보기 컨트롤러 사이를 탐색합니다. 커스텀 segue는 CGAffineTransformMakeScale을 사용하여 대상 컨트롤러에 확대/축소 효과를 만듭니다.가로 방향으로 올바른 방향을 사용하지 않는 맞춤 세구 방향

프로젝트를 세로 모드로 실행하면 모든 것이 정상적으로 작동하지만 가로로 변경하면 문제가 발생합니다. 대상 컨트롤러는 세로 방향으로 화면에 나타나고 올바른 배율 (1.0, 1.0)로 애니메이션되고 애니메이션이 완료되면 올바른 방향으로 변경됩니다. 이것은 정말 혼란스럽고이 문제에 관해서는 온라인으로 찾을 수 없기 때문에 어떤 도움을 주시면 대단히 감사하겠습니다.

이 테스트에 사용하는 프로젝트는 각보기를 트리거하는 단추가있는 두 개의보기 컨트롤러를 사용합니다.

이 내 CustomZoomSegue.m 파일입니다

#import "CustomZoomSegue.h" 

@implementation CustomZoomSegue 

- (void)perform 
{ 
    UIViewController *destinationViewController = (UIViewController *)self.destinationViewController; 
    UIViewController *sourceViewController = (UIViewController *)self.sourceViewController; 
    UIWindow *mainWindow = [[UIApplication sharedApplication].windows objectAtIndex:0]; 

    UIView *sourceView = [sourceViewController view]; 
    UIView *destinationView = [destinationViewController view]; 

    destinationView.frame = sourceView.frame; 
    [mainWindow addSubview:destinationView]; 

    [destinationView setAlpha:0.0f]; 
    [destinationView setTransform:CGAffineTransformMakeScale(0.0, 0.0)]; 

    // slide newView over oldView, then remove oldView 
    [UIView animateWithDuration:0.8 
        animations:^{ 
         [destinationView setTransform:CGAffineTransformMakeScale(1.0, 1.0)]; 
         [destinationView setAlpha:1.0f]; 
        } 
        completion:^(BOOL finished){ 
         [destinationView removeFromSuperview]; 
         [sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; 
        }]; 
} 

@end 

사람이 이런 일이 발생하는 이유 어떤 생각을 가지고 있습니까? 그것은 나를 미치게합니다.

답변

0

원본보기에 대상보기를 하위보기로 추가하여이 기능을 사용할 수 있습니다. 내가 메인 윈도우에 직접 추가하기 전에.

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

    [sourceViewController.view addSubview:destinationViewController.view]; 
    [destinationViewController.view setFrame:sourceViewController.view.window.frame]; 

    [destinationViewController.view setBounds:sourceViewController.view.bounds]; 
    CGSize screenSize = [[UIScreen mainScreen] bounds].size; 
    [destinationViewController.view setCenter:CGPointMake(screenSize.width/2 + 127, screenSize.height/2 - 138)]; 

    [destinationViewController.view setTransform:CGAffineTransformMakeScale(0.0,0.0)]; 

    [UIView animateWithDuration:1.8 
          delay:0.0 
         options:UIViewAnimationOptionCurveEaseOut 
        animations:^{ 
         [destinationViewController.view setAlpha:0.0]; 
         [destinationViewController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)]; 
         [destinationViewController.view setAlpha:0.8]; 
        } 
        completion:^(BOOL finished){ 
         [destinationViewController.view setAlpha:1.0]; 
         [destinationViewController.view removeFromSuperview]; 
         [sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; 
        }]; 
} 
: 여기

스케일을 관리하고 애니메이션 블록 동시에 줌 코드이며
0

View Controller를 표시하기 전에 대상보기에 애니메이션을 적용하는 것과 관련된 문제 일 수 있습니다. 컨트롤러는 뷰 회전에 관여하지만 제시 될 때까지 회전하라는 메시지는 표시되지 않습니다. 먼저 제시하고 소스 및 대상 뷰의 이미지를 사용하여 애니메이션을 수행하면 더 나은 결과를 얻을 수있을 것이라고 생각합니다.