(SDCAlertView)不调用AlertAction处理函数中的函数

时间:2016-06-24 02:17:56

标签: ios uialertcontroller dismiss sdcalertview sdcalertcontroller

用户在警报控制器上点击AlertAction(例如“发送按钮”)后,我想在警报控制器的文本字段中处理该值,而不会将其解除。

我知道,当用户点击警报控制器上的任何按钮后,来自Apple的内置UIAlertController会自然消失。所以我选择SDCAlertView(来自CocoaPods),用户点击按钮后不会忽略。但是,我遇到了一些问题。

我使用SDCAlertView通过以下代码创建了一个警报控制器:

let alert = AlertController(title: "Title", message: "This is a message")
alert.addAction(AlertAction(title: "Dismiss", style: .Default)) // the button do dismiss
alert.addTextFieldWithConfigurationHandler()

// the button that DO NOT dismiss
let sendAction = AlertAction(title: "Send", style: .Default, handler: { (sendAction) in

    // The following functions in the closure are not called after sendAction is tapped
    print("(alert.textFields![0].text)")
    // and further process to alert.textFields![0].text
    print("Send")
})

alert.addAction(sendAction)
alert.shouldDismissHandler = { $0!.title == "Dismiss" }
alert.present()

我想在sendAction按钮录制后处理文本字段中的值。但是,不调用这些函数。是否有可能解决这个问题?

谢谢!

0 个答案:

没有答案
相关问题