What is the difference between addChildViewController and presentModelViewController

China☆狼群 提交于 2019-12-04 02:12:27

These are four totally different implementations

  • addChildViewController is used in iOS5 to do viewController containment, this will enable you to easily create your own NavigationCotrollers or TabControllers its only available in iOS5

  • addSubview is the lowest level of the three, this will just add a view to another view, as a child

  • presentModalViewController is used to present a viewController modally on the screen, hence overwriting the old one

  • pushViewController used in UINavigationController to push a new ViewController to the viewcontrollers stack,

1) was introduced in iOS 5 as part of Apple's paradigm shift to allow view controller hierarchies, it just puts a view controller in front of the current one. You have to manage the flow of controllers.

2) Is the same as one, except it can only be done for one view controller at a time. Actually, this method has been superseded by [self presentViewController:animated:completion:]

3) Adds the view controller to a list so you can go back to the previous one after hitting 'back'. iOS will manage the flow of controllers for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!