The problem is that I have a different UILabel content for each cell and I want the width of the cell fixed and the hight flexible depending on the content which is UILabel hight , I tried deferent solutions for this problem and watched several tutorials but unfortunately it did not workout for me .
**I have one view controller and two collection views and I just need one of them to have a flexible hight **
extension TextViewController : UICollectionViewDelegateFlowLayout {
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
if collectionView == PagesCollectionView
{
return CGSizeMake(44.0, 44.0)
}
else {
width = UIScreen.mainScreen().bounds.width - CGFloat( 14 )
return CGSizeMake( width , hight )
}
}
Edit 1 :
Is there a simple way to do this like in table view ?
example : -
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.estimatedRowHeight = 80
self.tableView.rowHeight = UITableViewAutomaticDimension }