“Incorrect” frame / window size after re-orientation in iPhone

前端 未结 3 449
南旧
南旧 2020-11-28 07:47

In my iPhone OS application I want (need) to watch for changes in the device orientation in order to rearrange certain portions of the screen. The approach I used was to use

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 07:58

    The orientation of your device changed, not the physical characteristics of the screen. You basically tipped it on its side, but in reality it is 320 pixels wide (20 of which are not available to you at the moment since the status bar is showing) and 480 pixels tall. If your view is auto-rotating, then the width/height have been translated for you, but when you ask for the actual dimensions of the screen, you get back the actual dimensions of the screen.

    This is also why, when working with translated views, it is important to do calculations based on the view's center and the view's bounds and never on the view's frame.

提交回复
热议问题