【发布时间】:2017-01-09 05:18:42
【问题描述】:
点击表格单元格后,我会延迟 4 到 5 秒来显示警报视图。下面是代码
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
let cell = tableView.cellForRow(at: indexPath)!
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .alert)
let ok = UIAlertAction(title: "Ok", style: .default, handler: { (action) -> Void in
let cell = tableView.cellForRow(at: indexPath)!
})
let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
})
alertController.addAction(ok)
alertController.addAction(cancel)
present(alertController, animated: true, completion: nil)
}
如何避免这种延迟?
【问题讨论】:
-
动画看起来慢吗?
-
不,是需要显示的动作方法,即'Ok'和alert controller中的'Cancel'。
-
你在任何地方的后台线程上吗?
标签: ios swift uitableview uialertcontroller