我有一些UITableView
從內部array
數據。我想顯示UIAlertController
,但我遇到了非常奇怪的延遲。奇怪的延遲與警報在UITableView
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("tapped \(dispatcher.conversations[indexPath.row].name)") //this one works fine, no problems here
let message = dispatcher.conversations[indexPath.row].desc + "\n\nDo you wanna play this?"
let alertname = dispatcher.conversations[indexPath.row].name
let alert = UIAlertController(title: alertname, message: message, preferredStyle: .alert)
let actionOK = UIAlertAction(title: "Play", style: UIAlertActionStyle.default, handler: { (action) in
//play the file
})
let actionCancel = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: { (action) in
//cancel the file
})
alert.addAction(actionOK)
alert.addAction(actionCancel)
self.present(alert, animated: true, completion: {
//some code here
})
我的第一個警報有一些延遲,但它大多是好的。但是如果我試圖挖掘下一個細胞,我必須等待幾秒鐘才能顯示警報。
所以,看起來我沒有任何訪問我的數據的問題(打印工作很好),但不知怎麼的,它需要幾秒鐘後才顯示UIAlertController。
我做錯了什麼?
你在設備或模擬器測試它? –
兩者(結果相同)。 – lithium
你可以嘗試沒有插件的設備。 –