开发者

iPad orientation issue. When does the app begin to know about its orientation?

开发者 https://www.devze.com 2023-03-26 13:07 出处:网络
I am implementing an application which is locked to landscape only, containing a UIScrollView (the super view to add sub-views) and a UIPageControl.

I am implementing an application which is locked to landscape only, containing a UIScrollView (the super view to add sub-views) and a UIPageControl.

When I trying to add a sub-view in viewDidLoad, calculating its frame b开发者_运维百科y referencing its super view's frame, it is always portrait. But the sub-view added later (say in the scrollViewDidScroll, when user swipes to next page) is landscape.

I set a break point and found that the super view's size is 768*969 in viewDidLoad and 1024 * 713 later.

I suspect it is because the app doesn't know about the orientation at all when viewDidLoad thus everything is default to portrait layout. Am I right?

If so, when will the app know about the orientation for the first time?

Thanks.


The workaround I found was to reparent the scroll view under an intermediate view

 VC
  view
   view (intermediate view)
    scrollview

Then the frame of the scroll view was correct in viewdidload (previously without the intermediate view, the frame was in portrait right up until viewdidappear!)

0

精彩评论

暂无评论...
验证码 换一张
取 消