我已将segue
的标识符从ViewcontrollerA
设置为ViewcontrollerB
。但是下面的代码不起作用:
class ViewcontrollerA: UIViewController {
@IBOutlet weak var Tasks: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func move(sender: AnyObject) {
self.performSegueWithIdentifier("move", sender: sender)
}
}
当ViewController
被“点击”时,有没有办法导航到第二个UITextfield
?
任何帮助都会非常感激!
答案 0 :(得分:1)
假设您已经提供了 segue标识符和 segue kind
替换func move:
@IBAction func move(sender: AnyObject) {
self.performSegueWithIdentifier("move", sender: self)
}
添加以下代码:
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
if identifier == "move" {
return true
}
return false
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "move" {
let vc = segue.destinationViewController as! ViewcontrollerB
// you can additional work here with navigating VC Object
}
}
答案 1 :(得分:0)
如果您希望SecondViewController
继续点击UITextField
,那么您可以使用textFieldDidBeginEditing
的委托方法UITextField
func textFieldDidBeginEditing(textField: UITextField) {
self.performSegueWithIdentifier("SegueIdentifier", sender: self)
}