2016-10-02 39 views
0

在Swift中調用presentViewController之後有可能以某種方式調用pushViewController嗎?在swift中使用presentViewController之後調用pushViewController

或者至少我需要實施相同的行爲,當從左側出現新的UIViewController時。我開發的唯一選擇是假冒pushViewControllerCATransition(),但在這種情況下,新UIViewController外觀的機制不同於本機。

  • 當您使用本機pushViewController新的UIViewController出現在舊的與淡入淡出。
  • 當您使用僞造的presentViewController而新的UIViewController剛剛出現剛剛移出屏幕。

我也試過使用segue,但在這種情況下,新的UIViewController從底部出現。

因此,如果可能的話,我更願意在presentViewController之後致電pushViewController

謝謝。

+0

你嘗試過使用導航控制器並在故事板上製作賽格嗎? –

+0

@Lu_是的,它也顯示從底部新的'UIViewController',但我需要從左側 – Danny

+0

所以如果你有故事板中的segue,簡單performsegue方法應該做的工作 –

回答

1

您需要使用UINavigationController並將其設置爲rootViewController爲您要呈現的UIViewController(從底部 - 作爲modal)。

撥打presentViewControllerUINavigationController

然後就可以調用pushViewControllerUIViewControllers到導航棧,它會從側面而非底部滑動。

+0

這是一個好主意,但我在這裏看到兩件與我的模型不相符的東西。首先'UIModalTransitionStyleCoverVertical'只是IOS 9+,但我也需要這個解決方案IOS 8,其次在某些時候我會網絡設置'rootViewController'回來,我會得到不需要的動畫 – Danny

相關問題