ios - UITableView can't scroll while refreshing -
using parse downloading images, text etc. , using them in table view cells. however, while refreshing (when indicator animating in navigation bar) cannot scroll or move on app. if app has become unresponsive until table view done refreshing.
any appreciated.
here simple example on how dispatch different thread, download image , main thread when download done.
func downloadimageandupdateui(){ imageview?.image = nil if let imageurl = avalidurl{ //get image on thread let qos = int(qos_class_background.rawvalue) dispatch_async(dispatch_get_global_queue(qos, 0), { let imagedata = nsdata(contentsofurl: imageurl) //get main thread dispatch_async(dispatch_get_main_queue(), { if imageurl == self.requestedimageurl { //making sure if image still needed (or if user havent moved on else) if imagedata != nil{ self.imageview.image = uiimage(data: imagedata!) } } }) }) } }
Comments
Post a Comment