2014-07-24 8 views
5

맞춤형 UIViewControllerAnimationTransition 클래스가 이미 만들어져 있으며 탭 전환시이 애니메이션을 UITabBarController에 만들어야합니다.UITabBarController 애니메이션의 전환 위임자

tabBarController은 일반 탭 표시 줄을 사용하지 않습니다. 나는 그것이 같은 역할을 사용자 정의 구현을 가지고 있고, 버튼을 누를 때,이 코드를 호출 transitionDelegate 자체에 대한

tabBarController.selectedIndex = index 

은 현재 내가 tabBarController (서브 클래스)가 대리인으로합니다. 그러나 대리자 메서드 animationControllerForPresentedController은 실제로 호출되지 않습니다.

탭 표시 줄 컨트롤러가 자체 대리인으로 적합합니까? 그렇다면 전환 코드는 실제로 실제로 호출되지 않습니다.

+0

이 [1] [1] [여기 링크 설명 입력] 설명 여기 정말 좋은 해결 방법이 있습니다 : http://stackoverflow.com/a/5180104/2855836 – SleepsOnNewspapers

답변

11

animationControllerForPresentedController은 탭 표시 줄 컨트롤러에 대한 잘못된 접근 방법입니다.

UITabBarController 하위 클래스에서 프로토콜을 채택하고 자체적으로 delegate으로 설정합니다. 그런 다음 tabBarController: animationControllerForTransitionFromViewController: toViewController:을 사용하여 사용자 지정 UIViewControllerAnimatedTransitioning 개체를 반환합니다.

더 나은 시각화를 얻으려면 TabBarDemo 폴더에서 VCTransitionsLibrary을보십시오.

+0

'UITabBarControllerDelegate' 대신'UIViewControllerTransitionDelegate'가되어서는 안됩니까? –

+0

아니,'transitionDelegate' 대신 'delegate'하지 않아야합니다. 내 잘못이야. –

+0

@ AndréFratelli는 그렇게 생각하지 않습니다. 위임자와 전환 대리인은 다른 작업을 수행합니다. 대리자는 버튼을 누를 때와 같이 전환 위임자가 애니메이션을 처리하는 등의 이벤트를 처리합니다. – erdekhayser

0

위와 같은 위임 메서드를 사용 했습니까?

@interface BTSlideInteractor : NSObject <UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate> 

- (IBAction)showModalButtonWasTouched:(id)sender 
{ 
    BTSlideInteractor *interactor = [[BTSlideInteractor alloc] init]; 
    interactor.presenting = YES; 

    BTModalViewController *modalController = [self.storyboard instantiateViewControllerWithIdentifier:@"ModalViewController"]; 
    modalController.modalPresentationStyle = UIModalPresentationCustom; 
    modalController.transitioningDelegate = interactor; 
    [self presentViewController:modalController animated:YES completion:nil]; 
} 

사용 기준이 링크 : https://github.com/brightec/CustomViewControllerTransition/blob/master/test/BTViewController.m

것은 당신이 솔루션은 친절하게 당신의 코드를 추가 발견 didnt는 경우.

+0

인가는 당신은 trabition 델리게이트가 * 탭 컨트롤러가 아닌 뷰 컨트롤러 *에 대해 설정되어야한다고 말했습니까? – erdekhayser

관련 문제