我正在尝试初始化UIView
。
我看到以下被抛出的异常:
0 libsystem_kernel.dylib 0x1853e7048 __abort_with_payload + 8
1 libsystem_kernel.dylib 0x1853e1bd8 abort_with_payload_wrapper_internal + 96
2 libsystem_kernel.dylib 0x1853e1b74 abort_with_reason + 32
3 libobjc.A.dylib 0x184b1be8c _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 108
4 libobjc.A.dylib 0x184b1bde4 _objc_fatal(char const*, ...) + 40
5 libobjc.A.dylib 0x184b1a610 _collecting_in_critical() + 372
6 libobjc.A.dylib 0x184b19e94 cache_collect + 68
7 libobjc.A.dylib 0x184b1a220 cache_fill + 268
8 libobjc.A.dylib 0x184b25894 lookUpImpOrForward + 564
9 libobjc.A.dylib 0x184b25628 lookUpImpOrNil + 8
10 libobjc.A.dylib 0x184b1a8c4 class_getMethodImplementation + 36
11 UIKit 0x18f171c78 +[UIView(Internal) _registerClassForIdiomInitializationIfNeccessary] + 64
12 UIKit 0x18ee8e3f4 UIViewCommonInitWithFrame + 376
13 UIKit 0x18ee8e208 -[UIView initWithFrame:] + 144
14 An App 0x104ca0404 -[myCustomView initWithFrame:] (myCustomView.m:20)
堆栈跟踪中的违规行是myCustomView的初始化函数:self = [super initWithFrame:frame]
上下文代码:
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// do some processing
}
return self;
我无法在本地重现此问题,但我已经收到有关此问题的报告。为什么self = [super initWithFrame:frame]
会导致崩溃?我的理解是超级意志最坏的是零,所以我们将返回零。 UIViews的initWithFrame是否存在内部错误?