码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2015-08-07 19:49:24      阅读:334      评论:0      收藏:0      [点我收藏+]

标签: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缺陷

标签:ios7

原文地址:http://blog.csdn.net/hherima/article/details/47343223

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!