ios - Tableviewcell not displays image | Swift -


admin can add image/text, content displays, image doesn't after adding. need add text make image displayed. example can add lots of images, in table, not viewed until admin add text.

the thing convert image in base64, add array, , cellforrowatindexpath decode , add cell.

func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingimage image: uiimage, editinginfo: [string : anyobject]?) {      var data = nsdata()     data = uiimagepngrepresentation(image)!      let base64string = data.base64encodedstringwithoptions(nsdatabase64encodingoptions.encoding64characterlinelength)      let newimage = "imagebase64" + base64string      content.append(newimage)     self.dismissviewcontrolleranimated(true, completion: nil) }  func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell{      if content[indexpath.row].rangeofstring("imagebase64") == nil  {          let cell = self.articletableview.dequeuereusablecellwithidentifier("text cell", forindexpath: indexpath) as! texttableviewcell          cell.textarticle.text = content[indexpath.row] string          return cell      }     else{          let cell = self.articletableview.dequeuereusablecellwithidentifier("image cell", forindexpath: indexpath) as! imagetableviewcell          let imagestring = content[indexpath.row].stringbyreplacingoccurrencesofstring("imagebase64", withstring: "")          let decodeddata = nsdata(base64encodedstring: imagestring, options: nsdatabase64decodingoptions.ignoreunknowncharacters)          let decodedimage = uiimage(data: decodeddata!)          cell.backgroundcolor = uicolor.clearcolor()         cell.imagearticle.image = decodedimage          return cell      } 

how make image displayed immediately?

call self.tableview.reloaddata() in func imagepickercontroller after content.append(newimage) , maybe forgot


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -