I am trying to do something like this:
Basically, I am using a UICollectionView and the cells (3 diferent .xib).
So far, it works.
The thing I want to do is:
- Set a
autoheight - If rotate, add 1 row to the
UIColectionView2.1 If tablet, on portrait will have 2 rows and landscape 3 rows. (which basically is the same of point 2, only adding 1 row.
I have something like this:
extension ViewController {
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator){
setSizeSize()
}
func setSizeSize(){
if(DeviceType.IS_IPAD || UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight){
if let layout = myCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.estimatedItemSize = CGSize(width: 1, height: 1)
layout.invalidateLayout()
}
}else{
if let layout = myCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize
layout.invalidateLayout()
}
}
myCollectionView.collectionViewLayout.invalidateLayout()
}
}
Does not work. Also, it freezes device. On simulator works parcially. (I'm trusting more device)
I also tried this, but it works sometimes...
Please, let me know if you need more info.
Thank you all in advance for the help.