Questions about several full screen view switches in a controller

Source: Internet
Author: User

We often encounter the need to implement multiple view switches within a controller.


a convenient way to achieve this is to use the Addchildviewcontroller function to add a child controller to the master controller, The corresponding sub-controller's view is then added to the main controller's main view as Subview for the first time by Transitionfromviewcontroller Toviewcontroller to implement the view switch. This is a good and convenient way.

But the sub controller's view needs to set the corresponding frame, can add to the correct position, realizes the correct switch. The frame of the view that was shown for the first time is different from the frame of the view that is displayed after the switch, (although we see the same height), which may be because the first display was implemented by Addsubview, while the others were Transition to achieve.


The specific height setting:

1. The height setting of the view that is not the first display is exactly the height we see, and the height of the screen minus some of the controls. Typically includes the navigation bar status bar height, toggle control height, and so on.

2, the first (default) display of the height of the view, only the screen height minus the height of the control used to switch. Note that this switch is used in the control, because sometimes nested multi-layer switching, switching inside and switching, then subtract is only the height of the switch.

3, the child controller internal view or according to the actual height set, such as have a tableview, height is also need to subtract all the height of the control, that is, we see the actual height.


If the height is set incorrectly, it can cause events that are out of range to be unresponsive and other strange phenomena.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Questions about several full screen view switches in a controller

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.