After researching a bit I have came up with the following way to solved this issue of AutoLayout
with UICollectionViewCell
. From Xcode 6 CollectionViewCell
doesn’t show the contentView
in interface builder, so in the awakeFromNib
of cell I have set its autoresizingMask
and it works like charm.
class CustomCell: UICollectionViewCell {
@IBOutlet
var imageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
//Below line solved my problem
self.contentView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
}
}
solved Constrains for ImageView is not working