I have a view controller with some nested views in portrait mode, but I need to know if its posible to generate a variation on landscape where I only have one image (deleting all my elements that I have in portrait view) or I need to create another view controller for this case.
Asked
Active
Viewed 425 times
1
-
Short answer? Sure you can. However, your question is so vague it's impossible to help you. What have you tried? What *specific* issue are you facing? Do you know which overrides to tap into when orientation changes? When you say "delete", do you mean "hide"? Finally, what about when a user **returns** from landscape to portrait? – Apr 20 '18 at 19:46
-
Sorry, I need to show a register form with a labels and textfields in portrait and in landscape i only need an image, its posible create a variation and delete these controls to only have a image ?, or I need to create a viewcontroller for each case – Ghost Apr 20 '18 at 21:14
1 Answers
3
you can change that in code using traitcollection
For your case
you can use below condition which presents landscape
orientation
if traitCollection.verticalSizeClass == .compact {
labelName.isHidden = true // hide label
textfield.isHidden = true // hide text
imageName.isHidden = false // unhide image
}
Note: you have also traitcollection.horizontalSizeClass
and it can be .compact
or .regular
according to which orientation of the device you want to edit and the type of device you are working on.

Community
- 1
- 1

Mina Gerges
- 319
- 3
- 15