繁体   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