Autolayout and subviews

戏子无情 提交于 2019-12-18 10:41:07

问题


I am using the iAd suite with storyboards from Apple, as per this link... Apple iAd Storyboard documentation

It all works fine until I turn autolayout on. It builds fine but crashes on running. The output I get is:

2013-08-24 12:06:36.138 TabbedBanner[7272:c07] * Assertion failure in -[UIView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2380.17/UIView.m:5781 2013-08-24 12:06:36.139 TabbedBanner[7272:c07] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after sending -viewDidLayoutSubviews to the view controller. BannerViewController's implementation needs to send -layoutSubviews to the view to invoke auto layout.' *** First throw call stack: (0x1e27012 0x110ee7e 0x1e26e78 0xba4665 0xa347a 0x11226b0 0x1358fc0 0x134d33c 0x1358eaf 0x1422bd 0x8ab56 0x8966f 0x89589 0x887e4 0x883ef 0x65c9d 0x5098b 0x5194b 0x62cb5 0x63beb 0x55698 0x1700df9 0x1700ad0 0x1d9cbf5 0x1d9c962 0x1dcdbb6 0x1dccf44 0x1dcce1b 0x5117a 0x52ffc 0x2a0d 0x2935) libc++abi.dylib: terminate called throwing an exception (lldb)

I know it is something to do with the subviews in storyboard but I dont know how to correct this error. I am pretty new to iOS and trying to teach myself so any help is appreciated. Many Thanks


回答1:


Add:

[self.view layoutIfNeeded];

to the end of this method

- (void)viewDidLayoutSubviews

inside your BannerViewController



来源:https://stackoverflow.com/questions/18429728/autolayout-and-subviews

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