簡體   English   中英

未激活按鈕激活的Segue

[英]Button Activated Segue Not Being Called

我有一個奇怪的問題。 我有兩個由表視圖控制器中的按鈕觸發的命令,這是導航控制器的根視圖控制器。 一種選擇會觸發,而另一種則不會。 它們來自兩個不同的按鈕,帶有兩個不同的標識符。

我在prepare(for segue: UIStoryboardSegue, sender: Any)放置了一個斷點prepare(for segue: UIStoryboardSegue, sender: Any)並且可以驗證第二個按鈕沒有調用它。 任何想法,將不勝感激。

我的代碼是:

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "locationViewSegue", let destinationViewController = segue.destination as? LocationViewController  {
            destinationViewController.delegate = self
            destinationViewController.weatherData = self.weatherData
            destinationViewController.wxObservationStationsArray = self.wxObservationStationsArray
            destinationViewController.newCoordinates = self.weatherData.locationCoordinates
        } else if segue.identifier == "searchPriorLocations", let destinationViewController = segue.destination as? SearchBarTableViewController  {
            destinationViewController.priorForecastLocations = self.priorForecastLocations

        }
    }

接下來,我的情節提要中突出顯示了令人討厭的話題: 故事板

任何想法,將不勝感激。

我有兩個按鈕觸發的選擇

我將建議實際上不,您不會。 其中一種情況可能是由按鈕觸發的。 這就是您所期望的效果-輕按按鈕會觸發segue。 但是,另一個序號雖然存在,但並非來自另一個按鈕。 它從單元或整個視圖控制器發出。

檢查此方法的方法是選擇按鈕並顯示“連接檢查器”:

在此處輸入圖片說明

如果您沒有看到-與按鈕相關聯的“動作”觸發的segue-點擊按鈕將不會觸發segue。

暫無
暫無

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

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