1
I performed a request that returned me some texts and 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 perform the process of inserting these elements in the table cell by the method cellForRowAtIndexPath
? why this event is triggered when it is started and when I go through the table, with this the images end up duplicating.
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 besides being poorly aligned there is a text to the right of it, below and loaded the same images.
In my Viewcontroller has a fun called loadPosts that returns the jsons, these jsons I put in the text array. I will do the tests changing to willdisplaycell, as for the alignment the settings are according to your post, until it was I who asked the question :)
– Gabriel Rodrigues
Ah is not even had seen , the jsons you speak is the object after the json parse? If you have a drawing of how you want more or less Cell I can help you with the constraints
– iTSangar
An example of the way I’m loading: https://github.com/Gabrielr47/tableWithImage
– Gabriel Rodrigues
I’ll take a look and make one
pull request
afterward.– iTSangar
I made the pull request. Take a look because it covers all that I wrote in the reply.
– iTSangar
I did the pull and to testing/ Adapting to my need, so have ok milestone as accepted worth.
– Gabriel Rodrigues