ios - How to force a UIView to update -
i working on application downloading json data server, , displays on uiview. view updated, takes 15 seconds. have tested make sure not download delaying update, , if change view's background color adding data waits update. correct in thinking view not updating, or else? how force view update? thanks.
var newview = customview(product: products[0],descriptive: false) contentview.addsubview(newview) let backheight = nslayoutconstraint(item: newview, attribute: nslayoutattribute.height, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.height, multiplier: 0.2, constant: 0) let backwidth = nslayoutconstraint(item: newview, attribute: nslayoutattribute.width, relatedby: nslayoutrelation.equal, toitem: contentview, attribute: nslayoutattribute.width, multiplier: 1, constant: 0) let backxposition = nslayoutconstraint(item: newview, attribute: nslayoutattribute.left, relatedby: nslayoutrelation.equal, toitem: contentview, attribute: nslayoutattribute.left, multiplier: 1, constant:0 ) let backyposition = nslayoutconstraint(item: newview, attribute: nslayoutattribute.top, relatedby: nslayoutrelation.equal, toitem: colorlabel, attribute: nslayoutattribute.bottom, multiplier: 1.0, constant: 0) view.addconstraints([backheight,backwidth,backxposition,backyposition])
this how adding items view.
when got data server can update ui view main queue shown in below code:
dispatch_async(dispatch_get_main_queue()) { //update ui here }
Comments
Post a Comment