ios - Search Bar results add image next to text -


is possible add image search bar results? i'm able add text using following:

override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier(self.identifier) as! uitableviewcell  var text: string?     if tableview == self.searchresultscontroller?.tableview {         if let results = self.results {             text = self.results!.objectatindex(indexpath.row) as? string         }     } else {       //  text = myvariables.users[indexpath.row] as? string     }      cell.textlabel!.text = text      return cell } 

you need add uiimage cell.

cell.imageview?.image = uiimage(named: "yourimagenamegoeshere") 

the imageview property of uitableviewcell placed on left.

[...] if image set, appears on left side of cell, before label. [...]

https://developer.apple.com/library/ios/documentation/uikit/reference/uitableviewcell_class/#//apple_ref/occ/instp/uitableviewcell/imageview

hope helps.


Comments