0
我試圖用textfield和一個按鈕實現當前行爲: 1 - 文本字段應該不是實時驗證,但只需點擊按鈕後,它必須顯示驗證的錯誤標籤錯誤 2 - 如果文本字段驗證我必須顯示一個uialertcontroller取消或繼續操作RxSwift和UIAlertController CocoaAction
我特別嘗試使用下面的代碼的第二部分,但它只有第一次,如果我點擊取消例如和我點擊另一個按鈕,它看起來像禁用....不允許更多的水龍頭。
let action = CocoaAction {
return Observable.create {
[weak self] observer -> Disposable in
let alertController = self.getAlertController()
let ok = UIAlertAction.Action(NSLocalizedString("OK_BUTTON", comment: "OK_BUTTON"), style: .Default)
ok.rx_action = CocoaAction { _ in
return self!.viewModel!.modify(self?.addressTextFiled.rx_text)
.doOnNext({ data in
if let data = data
{
self!.showMessage(data.message)
}
})
.map { _ in Void() }
}
let cancelAction = UIAlertAction(title: NSLocalizedString("CANCEL_BUTTON", comment: "CANCEL_BUTTON"), style: .Cancel) { (_) in }
alertController.addAction(ok)
alertController.addAction(cancelAction)
self!.presentViewController(alertController, animated: true, completion: nil)
return NopDisposable.instance
}
}
confirmButton.rx_action = action
對於第一點你有一些建議嗎?
感謝您的幫助!
你能仔細檢查「self!.viewModel!.modify」是否完成?如果未完成,則不會釋放要再次執行的操作。 –
您的意思是?如果它發送完成的事件? – jerrygdm