当我被选中时,按钮两次将打开一个新页面。
//////
主视图控制器
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]
}
}
}
////https://i.stack.imgur.com/LKrN7.jpg
我试过了,但没有意识到问题。
有谁知道这件事?:)
可能的原因是您已将按钮的续集连接到情节提要中的新视图控制器。按下按钮时,它将加载在情节提要中创建的 segue 以及以编程方式创建的 segue。
如果这是原因,那么您只需要删除情节提要 segue 并从 ViewController 而不是从按钮创建一个新序列。