当我向ZetaViewController添加调试日志记录时,我注意到 self.view.bounds.size.height 和 self.view.bounds.size.width 的尺寸相等到ContainerView(768 x 1004)和 not ZetaView(728 x 637). IB中的大小检查器会确认这些值.我为ZetaView的tag属性创建了一个与众不同的值并将其记录下来. ZetaViewController.view 确实是ZetaView,因为标签值可以确认.那是怎么回事?为什么ZetaView在情节提要板上和大小"检查器中以较小的尺寸清晰显示,但在运行时在其属性中显示了错误的值?解决方案好的,我要指出的是我发现的一篇很棒的文章:(更新) http://kevindew.me /post/18579273258/在哪里可以在ios-5-和 中进行编程布局在自动布局完成其神奇功能后,我在视图中添加阴影层的时间很糟糕. viewDidLoad,viewWillLoad等没有正确布局所有内容. viewWillLayoutSubviews被调用了好几次,并且状态尚未完全设置.但是...在viewDidLayoutSubviews中,终于一切都按照我的预期进行了设置.This document outline from my sample Storyboard shows what I'm working with.I have a custom container view controller and two content view controllers connected via embed segues.Here is the storyboard itself.ZetaViewController has to create some programmatic views (within ZetaView, of course). I noticed when I was centering these programmatically created views they seemed really off center.ZetViewController is centering things by examining self.view.bounds.size.height and self.view.bounds.size.width and doing some appropriate arithmetic.When I added debug logging to ZetaViewController, I noticed that self.view.bounds.size.height and self.view.bounds.size.width had dimensions equal to ContainerView (768 x 1004) and not ZetaView (728 x 637). The Size Inspector in IB confirms these values.I created a distinctive value for the tag attribute of ZetaView and logged it. ZetaViewController.view really is ZetaView because the tag value confirms it.So what is going on? Why would ZetaView, shown clearly with smaller dimensions on the Storyboard and in the Size Inspector, show the wrong values in it's properties during run time? 解决方案 Ok,I'm going to point to an excellent post that I found: (updated)http://kevindew.me/post/18579273258/where-to-progmatically-lay-out-views-in-ios-5-andI was having an awful time adding shadow calayers to views after autolayout had done its magic. viewDidLoad, viewWillLoad etc did not have everything correctly laid out.viewWillLayoutSubviews is called quite a few times and the state isn't fully set up. However... In viewDidLayoutSubviews, finally everything was set up as I expected. 这篇关于子内容视图控制器视图的故事板的边界大小错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-14 11:13