[IOS] viewcontroller does not respond to messages related to horizontal and vertical screen Conversions

Source: Internet
Author: User

Viewcontroller does not respond to messages related to screen conversion.

Luo chaohui (http://blog.csdn.net/kesalin)

Reprinted please indicate the source

Some people raised the following question on cocoachina: A viewcontroller contains a B viewcontroller (B's view is used as the subview of A's view). During Horizontal and vertical screen conversion, A can get messages related to screen rotation (for example:Shouldautorotatetointerfaceorientation), And
B is not available, even if a and B Implement these functions. Original post see here: http://www.cocoachina.com/bbs/read.php? Tid = 40973 & page = 1 #393765.

I have encountered this problem before. I have studied it a little because a is in the Controller hierarchy of the window in appdelegate (for example, it is implemented by navigation push ), B is just created to make it easier for a to use its view. B is not added to this hierarchy (B's parentviewcontroller is nil, even if B. view. superview is. view ). So a will follow that hierarchy to get the message related to system rotation, while B will be cooler at one side and will not receive the message.

There are three solutions:

First, add B to the Controller navigation level;

The second is to implement all rotation-related messages in a, and explicitly call related messages of B in the messages implemented by;

Third, the layoutsubviews function of B is explicitly called in layoutsubviews of A. In layoutsubviews message implementation of B, the layout is adjusted based on the orientation of statusbar. This method only adjusts the layout of B and does not actually change the value of orientation of B.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.