今天在用container view controller時,發現我添加的三個sub view controller大小不對,原本應該是左中右三屏的。研究後發現是設置frame無效。經搜索發現是本身對View Controller Lifecycle仍是不理解(罪過啊。。)。將設置sub viewcontroller的frame的代碼移到viewDidAppear
or viewWillLayoutSubviews
等方法中便可。概述以下:html
具體緣由詳細閱讀如下連接中的文章便可:ios
http://blog.sina.com.cn/s/blog_76264a170101e5lb.htmlapp
http://www.samirchen.com/view-controller-lifecycle-in-ios/
iview
http://stackoverflow.com/questions/13079172/unable-to-set-frame-correctly-before-viewdidappear
post
http://stackoverflow.com/questions/9539676/uiviewcontroller-returns-invalid-frame
ui
http://stackoverflow.com/questions/11384696/view-controller-frame-size-in-child-controllerspa