2014-06-13 3 views
-2

새 컨트롤러가 화면의 오른쪽에서 중앙으로 슬라이드하는 반면, 이전 컨트롤러는 가운데에서 왼쪽으로 동시에 슬라이드하는 애니메이션을 수행해야합니다.iOS : 세그 크기가 작동하지 않습니다.

필자는 논리적으로 올바른 모든 차원을 입력했지만 세그 색은 매우 다른 동작을 수행합니다.

원하는 애니메이션 대신 새 컨트롤러가 가운데에 나타나며 화면 오른쪽으로 슬라이드됩니다.

UIViewController* src; 
UIViewController* dst; 

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



    float width = src.view.bounds.size.width; 
    float height = src.view.bounds.size.height; 

    dst.view.bounds = CGRectMake(width, 0, width, height); 


    [src.view addSubview:dst.view]; 


    [UIView animateWithDuration:5 animations:^{ 

     dst.view.bounds = CGRectMake(width, 0, width, height); 
     src.view.bounds = CGRectMake(-width, 0, width, height); 

    }]; 

    [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(present) userInfo:nil repeats:NO]; 

} 

- (void)present 
{ 
    [[self sourceViewController] presentViewController:[self destinationViewController] animated:NO completion:nil]; 
} 

답변

1

변화 :

dst.view.bounds = CGRectMake(width, 0, width, height); 

에 : 답장을

dst.view.frame = CGRectMake(-width, 0, width, height); 
+0

감사

이 내 코드입니다. 나는이 두 가지 문제가있다. 첫째, x 좌표를 -width로 설정 한 다음 다시 -width로 이동하면 아무 곳으로나 이동할 수 있습니다. 둘째, 오른쪽에서 왼쪽으로 스 와이프해야하며, 왼쪽에서 오른쪽으로 스 와이프하지 않아야합니다. 어떤 치수가 바뀌어야하는지 잘 모르겠습니다. 감사합니다. – Sam

+1

시도해 보셨습니까? 나를 위해 그것이 작동하고 - 나는 그것으로 새로운 프로젝트를 만들었습니다. 왼쪽에서 오른쪽으로 스 와이프되고 있습니다. 프레임과 발견 된 것에주의를 기울여야합니다. - 이것은 속임수입니다. –

+1

뭔가 명확하지 않은 경우 알려주세요. 제가 도와 드리려고 노력합니다. - 좋은 생각입니다. –

관련 문제