Autolayout and Device Orientation

后端 未结 4 1682
灰色年华
灰色年华 2021-01-05 09:51

I am developing an application which supports portrait and landscape modes. I am using auto layout to arrange my views. As i have been reading many

4条回答
  •  臣服心动
    2021-01-05 10:30

    The best approach is to use neither. Instead, configure your constraints correctly so that no programmatic changes are required on rotation. The Auto Layout runtime will maintain the views in position as you already have specified.

    Updating constraints other than changing the value of .constant is a real performance hit and should be avoided.

    Using viewWillLayoutSubviews is not necessary. Auto Layout methods are updateViewConstraints (for the view controller), and updateConstraints (in the views).

提交回复
热议问题