我有一些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
你可以尝试没有插件的设备。 –