I have the following detail.
I have a series of TableViews, in whose cells I am loading background images, like so:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! MenuSecundarioTVCell
let seccion = items[indexPath.row]
cell.titulo?.text = (seccion.value["nombre"] as! String)
//PONIENDO IMAGEN DE FONDO A CELDA
let imageBackground = UIImageView(frame: CGRectMake(0, 0, cell.frame.width , cell.frame.height+1))
if let imageRemote = seccion.value["imageBackground"]{
imageRemoteURL = NSURL(string: imageRemote as! String)
imageBackground.sd_setImageWithURL(imageRemoteURL!)
cell.backgroundView = UIView()
cell.backgroundView!.addSubview(imageBackground)
}
//TERMINANDO DE PONER IMAGEN DE FONDO A CELDA
return cell
}
I am using SDWebImage . The problem is that when the images are loaded into the cells they look like this:
After performing another action such as sliding the cells down or selecting the cell to go to the next view, when returning the image is rearranged in the correct way:
the images are test and it is clear that the resolution of the images does not match the height of the cells (120)
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 120
}
Will the origin of the problem be that the resolution of the images must match the size of the cells? I have seen this problem in some apps published in the appstore but the rearrangement is so fast that it is almost unnoticeable.
Add the
contentMode
elUIImageView
right when creating it so it will look right from the start. For example: