当我选择按钮两次时将打开一个新页面。
//////
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/