2011-12-04 4 views
2

사용자 정의 Segue Transition 내에서 CATransition을 사용할 수 있는지 궁금합니다. 내 CustomSegueTransition.m 파일을 작성한 후 사용자 정의 Segue 클래스에서 참조하여 전환이 발생하도록합니다. 버튼이로 자연스럽게 전환을 일으키는 누를 때 전환이 늘 수행사용자 정의 Segue에서의 전환

#import "CustomSegueTransition.h" 
#import "QuartzCore/QuartzCore.h" 

@implementation CustomSegueTransition 

-(void) perform { 

    // set up an animation for the transition the content 
    CATransition *animation = [CATransition animation]; 
    [animation setDuration:0.25]; 
    [animation setType:kCATransitionPush]; 
    [animation setSubtype:kCATransitionFromRight]; 
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.25]; 

    [UIView commitAnimations]; 
} 

@end 

그것은 나에게 오류 경고를 제공하지 :

이것은 CustomSegueTransition.m 파일에 대한 내 코드입니다. CATransition 코드에 뭔가 빠져 있거나 이것이 가능하지 않습니까?

감사합니다.

@Grant

답변

1

나는 당신을 위해 완전한 답변이없는,하지만 난 당신이 새로운보기 때문에 아무런 변화가없는 전화 결코 통지를했다. 내가 믿는

UIViewController *src = (UIViewController *) self.sourceViewController; 
UIViewController *dst = (UIViewController *) self.destinationViewController; 
[src presentModalViewController:dst animated:YES]; 

또는

[src presentViewController:<#(UIViewController *)#> animated:<#(BOOL)#> completion:<#^(void)completion#>]; 

다른있다 : 당신이 푸시, 팝, 또는 모달를 위해 촬영하고 있지만, 여기에 추가해야합니다 코드의 유형인지 모른다 솔루션에 관심이 있지만 사용자 정의 애니메이션 설정에 대한 문제가 있습니다.

+1

'presentModalViewController : animated :'는 더 이상 사용되지 않으므로'presentViewController : animated : completion :'이이 경우에 사용되어야합니다. –

0

어떤 것을 시도했는지 확실하지 않지만 문제를 발견했습니다.

전환 애니메이션을 만들었지 만 사용하지 않았습니다. 애니메이션하려는 뷰의 레이어에 애니메이션을 추가해야합니다.

하단 레버 CoreAnimation 기능을 사용하려는 경우에도 [UIView beginAnimation] ... [UIView commitAnimation]을 사용할 필요가 없습니다.

필요하면 [CATransaction begin] ... [CATransaction commit]을 사용하십시오.

0

여기

-(void)perform { 

__block UIViewController *sourceViewController = (UIViewController*)[self sourceViewController]; 
__block UIViewController *destinationController = (UIViewController*)[self destinationViewController];      

CATransition* transition = [CATransition animation]; 
transition.duration = .25; 
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
transition.type = kCATransitionMoveIn; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade 
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom 

[sourceViewController.navigationController.view.layer addAnimation:transition 
              forKey:kCATransition]; 

[sourceViewController.navigationController pushViewController:destinationController animated:NO]; 

} 
0

수입 QuartzCore 프레임 워크를 작동하는 전체 코드입니다. 그것은 사용자 정의 전환 효과와 함께 탐색 컨트롤러에 뷰 컨트롤러를 밀어 쉬운 코드는 간단하고

- (void)pushViewWithCustomTranstion { 
    CATransition* transition = [CATransition animation]; 
    transition.duration = 0.4f; 
    transition.type = kCATransitionMoveIn; 
    transition.subtype = kCATransitionFromRight; 
    [self.navigationController.view.layer addAnimation:transition 
               forKey:kCATransition]; 
    YourDestinataionController *yourVC = [[YourDestinataionController alloc] init]; 
    [self.navigationController pushViewController:yourVC animated:NO]; 
} 

.

관련 문제