문제

나는 사용자 정의 목소리는 내가 하려고 하는 반전의"라는 표준 커버의 수직"자연스럽게 전환됩니다.나는 생각이 작동:

UIView *srcView = ((UIViewController *)self.sourceViewController).view;
UIView *dstView = ((UIViewController *)self.destinationViewController).view;

[dstView setFrame:CGRectMake(0, 0, srcView.window.bounds.size.width, srcView.window.bounds.size.height)];

[srcView.window insertSubview:dstView belowSubview:srcView];

[UIView animateWithDuration:0.3
     animations:^{
         srcView.center = CGPointMake(srcView.center.x - srcView.frame.size.width, srcView.center.y);
     }
     completion:^(BOOL finished){
         [srcView removeFromSuperview];
     }
 ];

문제를 대상은 보기에는 세로 방향으로더라도 다른 모든 보 응용 프로그램에서 가로 방향입니다.또한,x,y 좌표은 반대입니다.왜 이런 일이 무엇입니까?

나는 설정 shouldAutorotateToInterfaceOrientation 에서 보기 컨트롤러,그러나 그 도움이 되지 않았습니다.수 돌보기 CGAffineTransformMakeRotation, 지만,없는 것 같은 옳은 일;좌표는 여전히 반대하고,하나를 위한 것입니다.

업데이트:

CGAffineTransformRotate 뷰를 회전하지만,그것은 말도 보인다.대부분의 배경을 보여줍 블랙.나는 생각하지 않는 이 방법입니다 그것은 생각을 작동합니다.

도움이 되었습니까?

해결책 3

분명히 그것보다 훨씬 쉽게 생각하 segue 있습니다.여기에 무슨 일:

- (void)perform {
    UIViewController *src = (UIViewController *)self.sourceViewController;
    [src dismissViewControllerAnimated:YES completion:^(void){ [src.view removeFromSuperview]; }];
}

희망이 다른 사람을 도움이 됩니다.

다른 팁

이후 나는 할 수 없 get 올바른 방향 및 프레임의 목적지기 전에 컨트롤러 exchange,나는 반대로 프로세스:

  1. 저장 원본 뷰로 이미지(참조하십시오 Remove 사용자 지정 UIStoryboardSegue 사용자 정의 애니메이션 ) ;
  2. 스위치는 현재 컨트롤러[presentViewController:...];
  3. 그런 다음을 수행합니 애니메이션(지정)대상보기 포함된 소스 이미지입니다.

여기에 완벽한 코드:

#include <QuartzCore/QuartzCore.h>

@implementation HorizontalSwipingSegue

- (void) perform {
    UIViewController *source = self.sourceViewController;
    UIViewController *destination = self.destinationViewController;    
    UIView *sourceView = source.view;
    UIView *destinationView = destination.view;

    // Create a UIImageView with the contents of the source
    UIGraphicsBeginImageContext(sourceView.bounds.size);
    [sourceView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageView *sourceImageView = [[UIImageView alloc] initWithImage:sourceImage];

    [[self sourceViewController] presentViewController:[self destinationViewController] animated:NO completion:NULL];

    CGPoint destinationViewFinalCenter = CGPointMake(destinationView.center.x, destinationView.center.y);
    CGFloat deltaX = destinationView.frame.size.width;
    CGFloat deltaY = destinationView.frame.size.height;

    switch (((UIViewController *)self.sourceViewController).interfaceOrientation) {
       case UIDeviceOrientationPortrait:
            destinationView.center = CGPointMake(destinationView.center.x - deltaX, destinationView.center.y);                
            sourceImageView.center = CGPointMake(sourceImageView.center.x + deltaX, sourceImageView.center.y);
            break;
        case UIDeviceOrientationPortraitUpsideDown:
            destinationView.center = CGPointMake(destinationView.center.x + deltaX, destinationView.center.y);
            sourceImageView.center = CGPointMake(sourceImageView.center.x + deltaX, sourceImageView.center.y);
            break;
        case UIDeviceOrientationLandscapeLeft:
            destinationView.center = CGPointMake(destinationView.center.x, destinationView.center.y - deltaY);                
            sourceImageView.center = CGPointMake(sourceImageView.center.x + deltaY, sourceImageView.center.y);
            break;
        case UIDeviceOrientationLandscapeRight:
            destinationView.center = CGPointMake(destinationView.center.x, destinationView.center.y + deltaY);
            sourceImageView.center = CGPointMake(sourceImageView.center.x + deltaY, sourceImageView.center.y);
            break;
    }

    [destinationView addSubview:sourceImageView];

    [UIView animateWithDuration:0.6f
                     animations:^{
                         destinationView.center = destinationViewFinalCenter; 
                     }
                     completion:^(BOOL finished){
                         [sourceImageView removeFromSuperview];
                     }];
}

@end

업데이트에 대답:

고 있는지 확인정 dstView 의 프레임습니다.나는 당신을 생각해야 더 나은 행운을 사용:

dstView.frame = srcView.frame;

는 대신:

[dstView setFrame:CGRectMake(0, 0, srcView.window.bounds.size.width, srcView.window.bounds.size.height)];

bounds 제공하지 않는 변화에 대응 방향이 같은 방법 frame 는 않습니다.

대체

[srcView insertSubview:dstView belowSubview:srcView];

[srcView insertSubview:dstView atIndex:0];

는 경우 추가 또 다른 보기 컨트롤러 보기 귀하의 계층 보기는 보 컨트롤러를 얻기 위하여 려고 하고 있지 않는 모든 정보는 방향에 대한의 장치,그래서 그것은 현재 보기 기본 구성에서.을 추가해야 합 보기 컨트롤러 보기 컨트롤러 계층 구조뿐만 아니라,사용하여 격리 방법을 설명 .당신이 또한 필요를 제거 계층구조에서 수행 할 때.

거기에는 또한 몇 가지 좋은 곧 회담에서 주제 중 하나에서 2011 년"이라고 구현하 보기 컨트롤러 격리"및 중 하나에서 올해의 진화를 보 컨트롤러입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top