美文网首页
自定义view controller

自定义view controller

作者: winnisz | 来源:发表于2017-03-07 17:16 被阅读0次

    2容器视图控制器:custom your container view controller

    * What is the role of the container and what role do its children play?

    * How many children are displayed simultaneously?

    * What is the relationship (if any) between sibling view controllers?

    * How are child view controllers added to or removed from the container?

    * Can the size or position of the children change? Under what conditions do those changes occur?

    * Does the container provide any decorative or navigation-related views of its own?

    * What kind of communication is required between the container and its children? Does the container need to report specific events to its children other than the standard ones defined by the UIViewController class?

    * Can the appearance of the container be configured in different ways? If so, how?

    * Can the size or position of the children change? Under what conditions do those changes occur?The parent-child relationship ensures that the children receive any relevant system messages.most of the real work happens during the layout and management of the contained viewsAdding a Child View Controller to Your Content

    * Call the addChildViewController: method of your container view controller. This method tells UIKit that your container view controller is now managing the view of the child view controller.

    * Add the child’s root view to your container’s view hierarchy.Always remember to set the size and position of the child’s frame as part of this process.

    * Add any constraints for managing the size and position of the child’s root view.

    *

    * Call the didMoveToParentViewController: method of the child view controller.set up constraintsDo not alter the contents of the root view or any other views in the child’s view hierarchy.Removing a Child View Controller

    *

    * Call the child’s willMoveToParentViewController: method with the value nil.

    * Remove any constraints that you configured with the child’s root view.

    * Remove the child’s root view from your container’s view hierarchy.

    * Call the child’s removeFromParentViewController method to finalize the end of the parent-child relationship. A child view controller should focus on its own content.Let a child view controller determine the status bar style.Let the child specify its own preferred size.

    相关文章

      网友评论

          本文标题:自定义view controller

          本文链接:https://www.haomeiwen.com/subject/cwnmgttx.html