swift - How to size CollectionViewCell dynamically using iOS 8 methods -
I'm trying to implement self-size cells on iOS 8 for a collectionView. However, the estimated item's system properties setting is not enough. I have also applied preferred layout attendants fitting properties but the cells should be closed.
Do I miss
in my ViewController:
override function viewDidLayoutSubviews () {super.viewDidLayoutSubviews () on flowLayout = collectionView.collectionViewLayout Where does this value come from UICollectionViewFlowLayout var width = collectionView.frame.width //? It's not supposed to be dynamic anymore ??? FlowLayout.estimatedItemSize = CGSizeMake (width, 100.0); }
Cell class:
@IBOptlet title title: UILabel! @IBOutlet var See the stars: HCview! @IBOOTletVar starsSubtitle: UILBL! @IBootlet Ward Body Labels: UILBL! @IBOutlet var footer label: UILBL! @IBOutlet var line: UIView! // I thought we do not need to implement any other thing ???? Why are we basically calculating the size for everything // if the auto line is using ??? Override function preferredLayoutAttributesFittingAttributes (layoutAttributes: UICollectionViewLayoutAttributes) - & gt; UICollectionViewLayoutAttributes! {Var attr = layoutAttributes.copy () as UICollectionViewLayoutAttributes var bodySize = bodyLabel.sizeThatFits (CGSizeMake (CGRectGetWidth (layoutAttributes.frame), CGFloat.max) var title system = title labeled sizeThatFits (CGSizeMake (CGRectGetWidth (layoutAttributes.frame), CGFloat max)) VIR SITESSbitis = StarsSubtitleSizeFits (CGCextMake (CGRactetGate (layoutAttivant.fr), CGFLot.mx) var Fuyure LabelsConcil = PatelLabil.SignatFits (CGCCMMAC (CGRXXDead (LayoutAttiv.fr), CGF Lotmax.)) VargaFreeFrame = Etror frame newFrame.size.height = bodySize.height + titleSize.height + starsSubtitleSize.height + footerLabelSize.height attr.frame = newFrame return attr}
Cell too It ends up being shortened, and the body has been removed ...
Comments
Post a Comment