来自 TextField 的 iOS 9 Swift Segue

标签 ios swift segue

我试图在用户单击 UITextField 上的“输入”后立即启动 UIActivityIndi​​cator。因为一旦他们点击进入应用程序获取存储在网络中的信息,我希望用户知道该应用程序正在运行。

Web 获取发生在 shouldPerformSegueWithIdentifier 函数内,根据结果确定是否会发生 segue。

那么,当用户单击返回键时开始调用的方法的顺序是什么。我想在那一刻启动 UIActivityIndi​​cator。我尝试了“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/

相关文章:

iOS 订阅 DID_CHANGE_RENEWAL_STATUS 通知 : latest_expired_receipt vs latest_receipt

ios - 单击按钮快速重新加载 Collection View 不起作用

swift - 在 Core Bluetooth 的中央显示 CBService 和 CBCharacteristic 名称的问题

ios - 在 Swift 中以编程方式使用 segues 传递信息

ios - 多少像素着色器周期对 iPad2 来说太重了

ios - 在其 View 加载之前设置 UITabBarItem 属性?

iphone - 在现有库周围使用我自己的 UIAlertView

ios - 如何打印相机闪光灯是否打开(Swift 4)

ios - 单击提要中的个人资料 - swift

ios - 隐藏目标 VC-Swift 中的开关