2013-09-30 31 views
5

自iOS7以來,我們可以使用UIViewControllerTransitioningDelegate創建從視圖控制器到視圖控制器的自定義轉換,從而實現細粒度轉換。iOS7使用Storyboard實現UIViewControllerTransitioningDelegate

viewController.transitioningDelegate = transitioningDelegate; 

我發現,使用分鏡的時候我們已經有機會來創建使用自定義UIStoryboardSegue定製的轉變,但它似乎實現與故事板定製化的唯一途徑。

如何在使用故事板時實現轉換代理?

回答

3

檢查http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/

想法是使用- prepareForSegue:來設置transitioningDelegatemodalPresentationStyleUIModalPresentationCustom。那麼你的過渡代表將不得不照顧過渡。

+0

你好,我有一個問題:我沒有在'prepareForSegue'中設置'modalPresentationStyle',我在'animationControllerForPresentedController'和'animateTransition'方法之間有一段時間差距(它有0.4秒,有時甚至是0.7;我的過渡動畫長度爲1秒,加上這個差距,幾乎是兩倍。)我試圖找出在這個時間差距中發生了什麼,但這並非錯誤(我認爲),因爲我沒有可能造成這種延遲的過程。當我添加modalPresentationStyle = UIModalPresentationCustom時,這個差距就消失了。爲什麼如此?謝謝。 –

+0

只是一個猜測:如果你簡化你的設置,你可能會發現有一個動畫正在進行。可能是您設置視圖層次結構的方式不允許您看到此動畫。 –

相關問題