我试图在用户单击 UITextField 上的“输入”后立即启动 UIActivityIndicator。因为一旦他们点击进入应用程序获取存储在网络中的信息,我希望用户知道该应用程序正在运行。
Web 获取发生在 shouldPerformSegueWithIdentifier 函数内,根据结果确定是否会发生 segue。
那么,当用户单击返回键时开始调用的方法的顺序是什么。我想在那一刻启动 UIActivityIndicator。我尝试了“textFieldDidEndEditing 和 textFieldShouldReturn”,但它们都发生在 PrepareForSegue 和 ShouldPerformSegueWithIdentifier 之后。
非常感谢。
最佳答案
为什么不自己调用 textFieldShouldReturn
中的代码?
func textFieldShouldReturn(textField: UITextField) -> Bool {
activityIndicator.startAnimating()
//Do the web stuff
if shouldPerformSegue == true {
self.performSegueWithIdentifier("Some Identifier", sender: self)
}
return true
}
关于来自 TextField 的 iOS 9 Swift Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37798796/