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

在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];
}

参考这里

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值