Portrait mode
Landscape mode
Tab Bar implemented using UICollectionView
(CV). In the CV I have added 4 items:
addSubview(collectionTab)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0":collectionTab]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0":collectionTab]))
When I change the orientation the constraints are not working. Why? How can I fix it? I think the size of items is not recalculated when I change the view.
Size of items:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: frame.width/4, height: frame.height)
}