美文网首页
点击 TableViewCell 2次才能 model 的问题

点击 TableViewCell 2次才能 model 的问题

作者: 冰霜海胆 | 来源:发表于2017-08-21 17:56 被阅读11次

当点击 TableViewCell 的时候,如果是通过 model 方式到下一个控制器,那么会出现点击2次 cell 才触发的问题,可能由于主线程的问题导致的。

解决方案:手动包装在主线程中执行

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let secondVC = SecondViewController()

        DispatchQueue.main.async {
            self.present(secondVC, animated: true, completion: nil)
        }
}

相关文章

网友评论

      本文标题:点击 TableViewCell 2次才能 model 的问题

      本文链接:https://www.haomeiwen.com/subject/emrhdxtx.html