簡體   English   中英

在navigationController中呈現viewController

[英]Presenting viewController in navigationController

我的項目有問題。

我創建了從一個VC到另一個VC的自定義過渡。 工作正常,但我的項目正在擴展,因此我需要一個導航控制器。

func itemButtonTapped(item: Item?) {
    if let item = item {
        let itemVC = storyboard!.instantiateViewControllerWithIdentifier("ItemViewController") as! ItemViewController
        itemVC.item = item
        itemVC.transitioningDelegate = self
        //navigationController?.presentViewController(itemVC, animated: true, completion: nil) // #1
        //navigationController?.pushViewController(itemVC, animated: true) //#2
    }
}

上面的代碼旨在將viewController添加到現有的導航控制器中。

選項#1-它使用我的自定義過渡並顯示VC,但未將其放置在現有的navigiationController中

選項#2-它不使用我的自定義過渡,而是顯示嵌入在現有navigationController中的VC

我應該怎么做才能合並這些選項,以便可以使用自定義轉換顯示VC並將其添加到現有的NavigationController中?

UINavigationController是一個特例,您不能像普通視圖控制器那樣僅使用過渡委托。 相反,您需要遵循UINavigationControllerDelegate協議,並通過這些方法提供要實現的自定義過渡動畫。

此處的文檔:

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationControllerDelegate_Protocol/

暫無
暫無

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

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