你需要做的是點擊時關閉按鈕,然後以某種方式啓用它時,數據傳輸完成。
如果此數據傳輸異步調用,它可能有一個參數,您可以在一個完成塊派:
button.isUserInteractionEnabled = false
sendData(data) {
success in
button.isUserInteractionEnabled = true
}
如果不接受完成塊作爲參數,它可能會以不同的方式工作,如使用通知(射擊的通知具有特定名稱):
button.isUserInteractionEnabled = false
sendData(data)
// adding the observer that will watch for the fired notification
NotificationCenter.default.addObserver(self, selector: #selector(self.didFinishSendingData(_:)), name: Notification.Name(rawValue: "NOTIFICATION NAME GOES HERE"), object: nil)
func didFinishSendingData(_ notification: Notification?) {
button.isUserInteractionEnabled = true
}
如果您發佈代碼示例,我們絕對可以提供更多幫助。
你是說點擊的處理,但有延遲? (當使用'isEnabled = false'時。) –
這裏需要的實際代碼。 – matt