Can I use autolayout to provide different constraints for landscape and portrait orientations?

后端 未结 6 1852
旧巷少年郎
旧巷少年郎 2020-12-01 03:44

Is it possible to change the constraints when the device is rotated? How might this be achieved?

A simple example might be two images which, in portrait, are stacked

6条回答
  •  温柔的废话
    2020-12-01 03:57

    I am following the same approach as yours (no nib files or storyboards). You have to update your constraints in updateViewConstraints method (by checking the device orientation). There is no need to call setNeedsUpdateConstraints in updateViewConstraints because as soon as you change the device orientation the last method is called automatically.

提交回复
热议问题