[英]returned nil from -traitCollection, which is not allowed in Xcode 11 Beta
Assertion failure in UITraitCollection * _Nonnull returned nil from -traitCollection, which is not allowed? UITraitCollection 中的断言失败 * _Nonnull 从 -traitCollection 返回 nil,这是不允许的? when I try to run Xcode 11 beta in ios 13 it crashed.当我尝试在 ios 13 中运行 Xcode 11 beta 时它崩溃了。 I don't know what was wrong.我不知道出了什么问题。
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
)!我遇到了这个问题,因为我的代码库中一个未命名的以前的编码器,我经常诅咒,没有在实现UITraitEnvironment
(又名UIView
或UIViewController
)的类上调用[super init]
!
If I could wield a battle hammer backwards five years in time, I would.如果我能在五年内向后挥舞战锤,我会的。
This implementation in a subclass of UIViewController
…这个实现在UIViewController
的子类中……
- (id)initWithStartPositionPdf:(float)startPosition withScrollViewHeight:(float)scrollViewHeight {
_startPosition = startPosition;
_scrollViewHeight = scrollViewHeight;
self.isPdfView = YES;
return self;
}
was updated to…已更新为…
- (instancetype)initWithStartPositionPdf:(float)startPosition withScrollViewHeight:(float)scrollViewHeight {
self = [super initWithNibName:nil bundle:nil];
_startPosition = startPosition;
_scrollViewHeight = scrollViewHeight;
_isPdfView = YES;
return self;
}
and resolved the crash I started receiving in Xcode 11 / iOS 13.并解决了我在 Xcode 11 / iOS 13 中开始收到的崩溃。
This is how iOS 13 and Xcode 11 deal with the main thread checker inconsistencies.这就是 iOS 13 和 Xcode 11 处理主线程检查器不一致的方式。
basically, you are updating the UI from a background thread.基本上,您是从后台线程更新 UI。 Just make sure you're updating all your UI in the main thread.只需确保您在主线程中更新所有 UI。
Simply wrap the code that updates your UI inside DispatchQueue.main.async { }
.只需将更新 UI 的代码包装在DispatchQueue.main.async { }
。
Just simple put your code in main thread of UI update :只是简单地将您的代码放在 UI 更新的主线程中:
DispatchQueue.main.async
{
// Put your code here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.