簡體   English   中英

用於UITabBarController動畫的Transition Delegate

[英]Transition Delegate for UITabBarController animation

我已經創建了一個自定義的UIViewControllerAnimationTransition類,並且需要在切換選項卡時使其為UITabBarController設置動畫。

但是, tabBarController不使用常規選項卡欄。 我有一個類似於它的自定義實現,當按下按鈕時,它會調用以下代碼:

tabBarController.selectedIndex = index

目前我有tabBarController (子類)作為其自己的transitionDelegate的委托。 但是,委托方法animationControllerForPresentedController實際上從未被調用過。

標簽欄控制器是否可以成為自己的委托? 如果是這樣,為什么轉換代碼永遠不會被調用?

animationControllerForPresentedController是標簽欄控制器的錯誤方法。

在UITabBarController子類中,采用UITabBarControllerDelegate協議並將其設置為自己的delegate 然后,使用tabBarController: animationControllerForTransitionFromViewController: toViewController:返回自定義UIViewControllerAnimatedTransitioning對象。

為了獲得更好的可視化,看看VCTransitionsLibrary在TabBarDemo文件夾中。

您是否使用過這樣的委托方法?

@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

如果您沒有找到解決方案,請添加您的代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM