"Auto Layout still required after executing -layoutSubviews” iOS7上崩潰sdk缺陷

來源:互聯網
上載者:User

標籤:ios7

在iOS7系統上,我項目工程裡寫了一個CinemaMemberView,添加到一個viewController中,結果崩潰了。iOS8和iOS6上則不會崩潰。

Terminating app due to uncaught exception ‘NSInternalInconsistencyException‘, reason: ‘Auto Layout still required after executing -layoutSubviews. CinemaMemberView‘simplementation of -layoutSubviews needs to call super.‘

*** First throw call stack:
(
0   CoreFoundation                      0x073cf1e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                         0x070848e5 objc_exception_throw + 44
2   CoreFoundation                      0x073cf048 +[NSException raise:format:arguments:] + 136
3   Foundation                              0x04fc54de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4   UIKit                                         0x05466a38 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 567
5   libobjc.A.dylib                         0x0709682b -[NSObject performSelector:withObject:] + 70
6   QuartzCore                              0x06df545a -[CALayer layoutSublayers] + 148
7   QuartzCore                              0x06de9244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
8   QuartzCore                              0x06de90b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
9   QuartzCore                              0x06d4f7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
10  QuartzCore                             0x06d50b85 _ZN2CA11Transaction6commitEv + 393
11  QuartzCore                             0x06e0e5b0 +[CATransaction flush] + 52
12  UIKit                                        0x05414ce5 _afterCACommitHandler + 131
13  CoreFoundation                     0x0739736e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
14  CoreFoundation                     0x073972bf __CFRunLoopDoObservers + 399
15  CoreFoundation                     0x07375254 __CFRunLoopRun + 1076
16  CoreFoundation                     0x073749d3 CFRunLoopRunSpecific + 467
17  CoreFoundation                     0x073747eb CFRunLoopRunInMode + 123
18  GraphicsServices                   0x0906d5ee GSEventRunModal + 192
19  GraphicsServices                   0x0906d42b GSEventRun + 104
20  UIKit                                         0x053f7f9b UIApplicationMain + 1225
21  SOHUVideoHD                        0x0000d649 main + 121
22  libdyld.dylib                             0x0805a6d9 start + 1
23  ???                                           0x00000001 0x0 + 1
)

CinemaMemberView的layoutSubviews是這樣的:

-(void)layoutSubviews{    [super layoutSubviews];    if (self.layoutType == ECinemaViewType_Wide_button) {        [self layoutWideType];        [self layoutWideTypeOnlyButton];    }else if (self.layoutType == ECinemaViewType_Wide_logo){        [self layoutWideType];        [self layoutWideTypeOnlyLogo];    }    else {        [self layoutNarrowType];    }}

解決辦法是,將super layoutSubviews放到layoutSubviews的最後,問題是解決了,但真正崩潰的原因還不明確。

-(void)layoutSubviews{    /*邏輯代碼*/    ...    /*邏輯代碼*/    [super layoutSubviews];}

參考這裡

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

"Auto Layout still required after executing -layoutSubviews” iOS7上崩潰sdk缺陷

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.