UITableView and presentViewController takes 2 clicks to display

前端 未结 8 1507
独厮守ぢ
独厮守ぢ 2020-12-13 18:34

I am using a UITableView to present a variety of viewControllers. Depending on which index is clicked, it will present a different view controller, which can then be dismis

相关标签:
8条回答
  • 2020-12-13 19:30

    One reason for this behavior could be that your table view code, and thus the code to start up your other view controllers, is not executed on the main thread. But all code related to UI must be executed on the main thread to work correctly.
    Thus please ensure that the code runs on the main thread, e.g. by setting an appropriate break point.

    0 讨论(0)
  • 2020-12-13 19:31

    At the end of didSelectRow method, deselect it so that it's available for selection the next time.

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
     .
     .
     .
     tableView.deselectRow(at: indexPath, animated: false)
    }
    
    0 讨论(0)
提交回复
热议问题