I made a request that returned some texts and some urls with images, these images I need to load them along with the text in parallel in the table.
I am using Alamofire + AlamofireImage to load the texts / Images, my doubt and the following, I must carry out the process of insertion of these elements in the cell of the table by method cellForRowAtIndexPath
? why this event is triggered when it is started and when I scroll through the table, with this the images end up doubling.
Example:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
print("Evento acontece")
if self.verifyUrl(self.texto[indexPath.row]){
Alamofire.request(.GET, self.texto[indexPath.row])
.responseImage { response in
if let image = response.result.value {
let size = CGSize(width: 300.00, height: 130.0)
let aspectScaledToFillImage = image.af_imageScaledToSize(size)
cell.imageView?.image = aspectScaledToFillImage
}
}
}else{
cell.textLabel?.text = self.texto[indexPath.row]
}
return cell
}
Note that in addition to being misaligned, a text is located to the right of it, below it, and loaded with the same images.