gpt4 book ai didi

ios7 - [MyClass layoutSublayersOfLayer :] 中的断言失败

转载 作者:行者123 更新时间:2023-12-03 21:04:14 25 4
gpt4 key购买 nike

我在 UITextField 的子类中使用 AutoLayout,但有时我会收到以下错误/堆栈跟踪:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. KOAOneDigitTextField's implementation of -layoutSubviews needs to call super.'

*** First throw call stack:
(
0 CoreFoundation 0x0390d1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x034c08e5 objc_exception_throw + 44
2 CoreFoundation 0x0390d048 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0167e4de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x02615a38 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 567
5 libobjc.A.dylib 0x034d282b -[NSObject performSelector:withObject:] + 70
6 QuartzCore 0x01caf45a -[CALayer layoutSublayers] + 148
7 QuartzCore 0x01ca3244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
8 QuartzCore 0x01ca30b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
9 QuartzCore 0x01c097fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
10 QuartzCore 0x01c0ab85 _ZN2CA11Transaction6commitEv + 393
11 QuartzCore 0x01cc85b0 +[CATransaction flush] + 52
12 UIKit 0x025a49bb _UIApplicationHandleEventQueue + 13095
13 CoreFoundation 0x0389677f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
14 CoreFoundation 0x0389610b __CFRunLoopDoSources0 + 235
15 CoreFoundation 0x038b31ae __CFRunLoopRun + 910
16 CoreFoundation 0x038b29d3 CFRunLoopRunSpecific + 467
17 CoreFoundation 0x038b27eb CFRunLoopRunInMode + 123
18 GraphicsServices 0x0530c5ee GSEventRunModal + 192
19 GraphicsServices 0x0530c42b GSEventRun + 104
20 UIKit 0x025a6f9b UIApplicationMain + 1225
21 MyProject 0x0006e94d main + 141
22 libdyld.dylib 0x03e86701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我错过了什么?

最佳答案

我在自定义 View 中遇到了类似的问题,结果是我的一个自定义父类覆盖了 -layoutSubviews并调用 super ,只有它在打电话 super第一个而不是最后一个。对我来说修复它的是确保所有覆盖到 -layoutSubviews在我的项目中,形式如下:

- (void)layoutSubviews {
// Custom code which potentially messes with constraints
[super layoutSubviews]; // No code after this and this is called last
}

关于ios7 - [MyClass layoutSublayersOfLayer :] 中的断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24731552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com