从-traitCollection返回nil,这在Xcode 11 Beta中是不允许的 [英] returned nil from -traitCollection, which is not allowed in Xcode 11 Beta
问题描述
UITraitCollection中的断言失败* _Nonnull 从-traitCollection返回零,这是不允许的吗? 当我尝试在ios 13中运行Xcode 11 beta时,它崩溃了.我不知道怎么了.
Assertion failure in UITraitCollection * _Nonnull returned nil from -traitCollection, which is not allowed? when I try to run Xcode 11 beta in ios 13 it crashed. I don't know what was wrong.
推荐答案
[超级初始化]
我遇到了这个问题,因为我的代码库中经常被诅咒的一位以前未命名的编码员没有在实现UITraitEnvironment
的类(又名UIView
或UIViewController
)上调用[super init]
!
[super init]
I ran across this problem because one of the unnamed previous coders on my codebase, whom I frequently curse, didn't call [super init]
on a class that implements the UITraitEnvironment
(aka UIView
or UIViewController
)!
如果我能在五年后向后挥动战锤,我会的.
If I could wield a battle hammer backwards five years in time, I would.
此实现在UIViewController
...
- (id)initWithStartPositionPdf:(float)startPosition withScrollViewHeight:(float)scrollViewHeight {
_startPosition = startPosition;
_scrollViewHeight = scrollViewHeight;
self.isPdfView = YES;
return self;
}
已更新为…
- (instancetype)initWithStartPositionPdf:(float)startPosition withScrollViewHeight:(float)scrollViewHeight {
self = [super initWithNibName:nil bundle:nil];
_startPosition = startPosition;
_scrollViewHeight = scrollViewHeight;
_isPdfView = YES;
return self;
}
并解决了我开始在Xcode 11/iOS 13中收到的崩溃.
and resolved the crash I started receiving in Xcode 11 / iOS 13.
这篇关于从-traitCollection返回nil,这在Xcode 11 Beta中是不允许的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!