gpt4 book ai didi

swift - 当 UITextfield 上发生 touchup inside 事件时导航到另一个 View

转载 作者:行者123 更新时间:2023-11-28 06:39:23 26 4
gpt4 key购买 nike

我已经将 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)

}

}

UITextfield 被“点击”时,有没有办法导航到第二个 ViewController

非常感谢任何帮助!

最佳答案

假设您已提供segue identifiersegue kind

Replace func move:

 @IBAction func move(sender: AnyObject) {

self.performSegueWithIdentifier("move", sender: self)

}

Add below code:

  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
}
}

关于swift - 当 UITextfield 上发生 touchup inside 事件时导航到另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38375609/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com