ios - Image view added in collection view cell doesn't apply added constraints -
i've added image uicollectionviewcell , added constraints following image.
constraints:
- width of imageview = width of cell
- height of imageview = height of cell
- align imageview vertically in container (cell)
- align imageview horizontally in container (cell)
i'm deciding cell size @ run time using uicollectionviewdelegate method.
func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize { // calculating cell size , returning } issue:
in cellforitematindexpath method, when checked cell size , image view size both have different values. cell {w:82.0, h:145.77}, imageview {w:380.0,h:170}. image has same frame size set on storyboard. not adjusting based on constraints. there anyway can ensure have same size of cell ?
current fix: (?)
cell.imageview.frame = cell.bounds but doesn't make sense. why need set size explicitly, why constraints not applied?
check answer marius soutier: uicollectionview: different size items not calculated on reused items
the comment below answer solution looking for.
basically, have call reloaddata before return cgsize sizeforitematindexpath:.

Comments
Post a Comment