4

다음과 같은 상황이 발생합니다. 탐색을 위해 UINavigationController를 사용하는 앱이 있습니다.UINavigationController를 푸시하면서 UIView에 애니메이션 적용

특수 내비게이션 컨트롤러를 밀기 위해 맞춤 애니메이션을 축소하고 싶습니다. 내가 지금까지 잘 보았던 유일한 문제는 애니메이션이 시작되기 전에 "오래된"ViewController가 사라져서 새 viewcontroller가 백그라운드에서 이전 viewcontroller를 보는 대신 "아무것도"가 아닌 것을 줌인합니다. download

enter image description hereenter image description hereenter image description here

아무도 이전 뷰 컨트롤러 (image1에)가에 남아있는 새의 ViewController (이미지 3)을 애니메이션하는 방법을 알고 있나요 : 더 나은보기를 위해

내가 간단한 예제 응용 프로그램을 만들어 배경에 애니메이션을 적용하는 중 (이미지 2)?

/* THIS CANNOT BE CHANGED */ 
    AnimatedViewController *animatedViewController = [[AnimatedViewController alloc] initWithNibName:@"AnimatedViewController" bundle:nil]; 

    /* THIS CAN BE CHANGED */ 
    animatedViewController.view.transform = CGAffineTransformMakeScale(0.01, 0.01); 
    [UIView beginAnimations:@"animationExpand" context:NULL]; 
    [UIView setAnimationDuration:0.6f]; 
    animatedViewController.view.transform=CGAffineTransformMakeScale(1, 1); 
    [UIView setAnimationDelegate:self]; 
    [UIView commitAnimations]; 

    /* THIS CANNOT BE CHANGED */ 
    [self.navigationController pushViewController:animatedViewController animated:NO]; 

추가 정보 : 내 앱이 그렇게 간단하지 않습니다. 내 애플 리케이션을위한 three20 프레임 워크를 사용하지만 push 및보기 컨트롤러의 생성은 단순히 three20 무엇입니까 않습니다. 나는 내 코드 (THIS CAN BE CHANGED) 사이의 부분에만 연결할 수 있습니다. 나는 그 전후에 코드를 바꿀 수 없다 (많은 연구를 제외하고).

+0

원본보기로 팝하는 동안 동일한 애니메이션 (revese 방향)을 설정하는 방법 ..? –

답변

9

나는 이것을 매우 빨리 채웠다. 그 아이디어는 스케일 애니메이션이 완료된 후 pushViewController를 호출하는 것입니다. 확인

-(IBAction)animateButtonClicked:(id)sender { 
    animatedViewController = [[AnimatedViewController alloc] initWithNibName:@"AnimatedViewController" bundle:nil]; 
    animatedViewController.view.transform = CGAffineTransformMakeScale(0.01, 0.01); 

    [UIView animateWithDuration:0.6 
        animations:^{ 
         [self.view addSubview:animatedViewController.view]; 
         animatedViewController.view.transform=CGAffineTransformMakeScale(1, 1);      
        } 
        completion:^(BOOL finished){ 
         [animatedViewController.view removeFromSuperview]; 
         [self.navigationController pushViewController:animatedViewController animated:NO]; 
        }]; 

} 
+0

예 (내 샘플 응용 프로그램에서)이 잘 작동합니다. 하지만 내 응용 프로그램에서 이것을 사용하는 데 문제가 있습니다. 난 단지 대리인 콜백에서 일할 수 있습니다 : https://gist.github.com/f13b1da4114b7d8691d6이 위임 후에 pushviewcontroller는 – choise

+0

호출됩니다. 뷰는 두 번 렌더링됩니다. – choise

+0

@choise, 그래서 당신이 말하는 것은 pushViewController가 바로 이후에 호출되기 때문에 스케일 애니메이션이 완료 될 때까지 (즉, 0.6 초 기다리기) 함수에서 복귀 할 수 없다는 것입니다. –

0

한 방법은 (a 비트 추한) 이렇게하여 애니메이션을 수행하여 애니메이션이 완료되면,과 pushViewController 할 것이다. 애니메이션을 할 때, 제시 할 뷰 컨트롤러의 화면이 어떻게 보이는지 애니메이션으로 만들어야합니다. 애니메이션이 새로운보기로 끝나기 때문에 새로운보기가 화면에 나타나면 그냥 움직이는보기와 같으므로 아무 것도 바뀌지 않아야합니다.

관련 문제