I have an App for Iphone and Ipad.
in my UIViewController, the subviews installed depend of the different classes (CR, RC, CC, RR) because possible widths of the view are not the same.
This work very well on Iphone, because the width of the view is different, depending on the class (CR, RC, CC).
But for Ipad, the class is RR, no matter the orientation. Or in portrait and landscape, of course, width is not the same. In Interface Builder, I don't find a way to have subviews installed for Ipad in landscape and not in Portrait.
Is there a way to handle this, or do I have to handle this programatically?
Your ,last comment gave me an idea Claude. if I have 2 differnt storyboard for my UITableViewCell, I can write this in the
tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
of the uiViewController:
let cell : UITableViewCell
if view.traitCollection.className == "RR" {
if UIScreen.main.bounds.size.width < UIScreen.main.bounds.size.height{
cell = table.getCell(indexPath) as! class1
} else {
cell = table.getCell(indexPath) as! class2
}
}
where class2 is a descendant of class1
Class2 if a descendant of class1, and can have other UIView installed and as class1 and class2 don't have the same storyboard, the constraints wh-ill not be the same. I have to precise that I wrote the following extension;
extension UITraitCollection { public var className: String { get { return (horizontalSizeClass == .compact ? "C" : "R") + (verticalSizeClass == .compact ? "C" : "R") } } }