swift - 为什么两个连续的页面打开时带有 segue

标签 swift uitableview

当我选择按钮两次时将打开一个新页面。

//////

Main viewController

var Country = [] 
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
 @IBAction func taxiAction(sender: AnyObject) {
        let opt = ["1","2","3","4","5"]
        Country = opt

        performSegueWithIdentifier("viewPlaceSegu", sender: sender)
    }
...
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    // get a reference to the second view controller
    if segue.identifier == "viewPlaceSegu" {
        if let secondViewController = segue.destinationViewController as? TableViewPlace {

    // set a variable in the second view controller with the String to pass
            secondViewController.tnt = Country as! [String]
        }

    }
}

//// http://i.stack.imgur.com/LKrN7.jpg

我试过了,但没有意识到问题。

有人知道吗? :)

最佳答案

一个可能的原因是您已将 segue 从按钮连接到 Storyboard中的新 ViewController。当按下按钮时,它将加载在 Storyboard中创建的 segue 以及以编程方式创建的 segue。

如果这是原因,那么您只需要删除 Storyboard转场并从 ViewController 而不是从按钮创建一个新的转场。

关于swift - 为什么两个连续的页面打开时带有 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35583027/

相关文章:

ios - 如何在详细 View UIimage 中为右/左创建滑动手势

Swift Direction Request 无法在 if 语句中正确计算

xcode - SpriteKit 可以使用什么类型的游戏 map ?

ios - Firebase 云消息传递与 iOS 应用程序集成 - Swift 4

c - 如何阻止 Cocoapods 导入保护伞中的私有(private) header

SwiftUI UIViewRepresentable 和自定义委托(delegate)

ios - 如何在iOS 5中实现字母滚动?

UITableViewCells 中的 iOS 动态表单,检索值

swift - 无法在 UItableviewcell 中设置我的单元格的字体

ios - 使用 UICollectionViews 创建动态和多特征