標籤: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缺陷