簡體   English   中英

Segue兩次打電話-iOS

[英]Segue called twice - IOS

我在項目中使用VIP ,當我將用戶路由到另一個場景時,打開場景兩次,我的路由器像波紋管一樣? 如果您需要更多詳細信息,請告訴我。 謝謝

@objc protocol ListLanguageRoutingLogic
{
    func routeToStartPage(segue: UIStoryboardSegue?)
}

protocol LangSelectedDataPassing
{
    var dataStore: SelectLanguageDataStore? { get }
}

class RouterSelectLanguage: NSObject, ListLanguageRoutingLogic, LangSelectedDataPassing
{
    weak var viewControllerSelectLanguage: ViewControllerSelectLanguage?
    var dataStore: SelectLanguageDataStore?
    func routeToStartPage(segue: UIStoryboardSegue?) {
        print("BBB")
        let destinationVC = viewControllerSelectLanguage?.storyboard?.instantiateViewController(withIdentifier: "ViewControllerStartPage") as! ViewControllerStartPage
        var destinationDS = destinationVC.router!.dataStore!
        passDataToStartPage(source: dataStore!, destination: &destinationDS)
        navigateToStartPage(source: viewControllerSelectLanguage!, destination: destinationVC)
    }

    // MARK: Navigation
    func navigateToStartPage(source: ViewControllerSelectLanguage, destination: ViewControllerStartPage)
    {
        source.show(destination, sender: nil)
    }
    // MARK: Passing data
    func passDataToStartPage(source: SelectLanguageDataStore, destination: inout StartPageDataStore)
    {
        print("CCC")
        let selectedRow = viewControllerSelectLanguage?.tblView.indexPathForSelectedRow?.row
        destination.langSelected = source.langs?[selectedRow!]
    }
}

和:

在此處輸入圖片說明

解決了我的問題,我現在編輯了波紋管這樣的源代碼,並且很好地工作了:

@objc protocol ListLanguageRoutingLogic
{
    func routeToStartPage(segue: UIStoryboardSegue?)
}

protocol LangSelectedDataPassing
{
    var dataStore: SelectLanguageDataStore? { get }
}

class RouterSelectLanguage: NSObject, ListLanguageRoutingLogic, LangSelectedDataPassing
{
    weak var viewControllerSL: ViewControllerSelectLanguage?
    var dataStore: SelectLanguageDataStore?
    func routeToStartPage(segue: UIStoryboardSegue?) {
        let destinationVC = segue!.destination as! ViewControllerStartPage
        var destinationDS = destinationVC.startPageRouter!.dataStore!
        passDataToStartPage(source: dataStore!, destination: &destinationDS)

    }

    // MARK: Passing data
    func passDataToStartPage(source: SelectLanguageDataStore, destination: inout StartPageDataStore)
    {
        let selectedRow = viewControllerSL?.tblView.indexPathForSelectedRow?.row
        destination.langSelected = source.langs?[selectedRow!]
    }
}

暫無
暫無

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

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