bably bably - 1 year ago 119
iOS Question

Swift - Unable to change images in tableView sections

I have a tableView and on selection of button placed in the table View cell of the TableView, I want to place that particular tableView cell to a new section of the tableView. This is working fine for me.

My problem is that when I select the button. I have actually made the button's background view transparent and placed a imageView behind the button. But immediately on selection of the button, my imageView is not getting changed.
My imageView is getting changed only when I scroll the tableView up and down atleast once.

In my button selection method, I am doing the following


Still my tableView is not getting refreshed immediately.

What am I doing wrong? Please help me. Swift 2.0, XCode - 7.3.1

Answer Source

You need to reload the table on the main thread instead, using

dispatch_async(dispatch_get_main_queue(), { () -> Void in
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download