简体   繁体   English

应用程序在 iOS 13 上崩溃,因为 -traitCollection 返回了 nil,这是不允许的

[英]Application crashes on iOS 13 because of returned nil from -traitCollection, which is not allowed

I am working on Telegram source code from the archived repo and application crashes in every ViewController and I can see the following error.我正在处理归档存储库中的 Telegram 源代码,并且每个 ViewController 中的应用程序崩溃,我可以看到以下错误。 I also tried to comment out some codes but the crash just moves from one class to another.我还尝试注释掉一些代码,但崩溃只是从一个 class 移动到另一个。 Is there any way to stop traitCollection from causing these crashes?有没有办法阻止traitCollection导致这些崩溃?

Telegram[50090:787790] *** Assertion failure in UITraitCollection * _Nonnull _UIGetCurrentFallbackTraitCollection(void)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3899.13.13/_UIFallbackEnvironment.m:91
Telegram[50090:787790] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<Decorated498f14ad: 0x7f80e9d46b20; baseClass = UIImageView; frame = (0 0; 8 14); userInteractionEnabled = NO; layer = <CALayer: 0x6000023abc00>> returned nil from -traitCollection, which is not allowed.'

PS: I cannot switch to newer versions of Telegram iOS. PS:我无法切换到较新版本的 Telegram iOS。

I've tried this answer but it didn't help我试过这个答案,但没有帮助

Also I tried to run my lines of code using a async dispatcher but still no change我也尝试使用异步调度程序运行我的代码行,但仍然没有变化

First throw call stack:
(
0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff23b98958 +[NSException raise:format:arguments:] + 88
3   Foundation                          0x00007fff255eb7be -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4   UIKitCore                           0x00007fff46dd08bd _UIGetCurrentFallbackTraitCollection + 962
5   UIKitCore                           0x00007fff46dce21a +[UITraitCollection _currentTraitCollection] + 196
6   UIKitCore                           0x00007fff476366c6 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2386
7   QuartzCore                          0x00007fff2b030ef9 -[CALayer layoutSublayers] + 255
8   QuartzCore                          0x00007fff2b0358ff _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
9   QuartzCore                          0x00007fff2b041fe4 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
10  QuartzCore                          0x00007fff2af8a4a8 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
11  QuartzCore                          0x00007fff2afbfab3 _ZN2CA11Transaction6commitEv + 643
12  UIKitCore                           0x00007fff4715c27c _UIApplicationFlushRunLoopCATransactionIfTooLate + 104
13  UIKitCore                           0x00007fff471fd878 __handleEventQueueInternal + 6902
14  CoreFoundation                      0x00007fff23afbac1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15  CoreFoundation                      0x00007fff23afb9ec __CFRunLoopDoSource0 + 76
16  CoreFoundation                      0x00007fff23afb1c4 __CFRunLoopDoSources0 + 180
17  CoreFoundation                      0x00007fff23af5ecf __CFRunLoopRun + 1263
18  CoreFoundation                      0x00007fff23af56b6 CFRunLoopRunSpecific + 438
19  GraphicsServices                    0x00007fff3815cbb0 GSEventRunModal + 65
20  UIKitCore                           0x00007fff47162a67 UIApplicationMain + 1621
21  Telegram                            0x000000010bcbb0f4 main + 132
22  libdyld.dylib                       0x00007fff5123bcf5 start + 1
)

In case of old Telegram source code, TGSimpleImageView will cause this problem simply in traitCollection function put following code instead of 'return nil'如果是旧的 Telegram 源代码,TGSimpleImageView 将在 traitCollection function 中将以下代码而不是“return nil”简单地导致此问题

- (UITraitCollection *)traitCollection
{
    if (@available(iOS 13.0, *)) {
        [UITraitCollection setCurrentTraitCollection:[[UITraitCollection alloc]init]];
    } else {
        // Fallback on earlier versions
    };
    return [[UITraitCollection alloc]init];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 -traitCollection 返回 nil,这在 Xcode 11 Beta 中是不允许的 - returned nil from -traitCollection, which is not allowed in Xcode 11 Beta 在 iOS 13 中覆盖 traitCollection - override traitCollection in iOS 13 AVAudioPlayer 在 iOS 13 上崩溃 - AVAudioPlayer crashes on iOS 13 IOS 13 UIWindow 实例在应用程序启动期间为零 - IOS 13 UIWindow instance is nil during application launching RestKit崩溃,因为NSKagedObjectContext在RKResponseMapperOperation中为nil - RestKit crashes because NSManagedObjectContext is nil in the RKResponseMapperOperation iOS-compelationHandler:nil导致应用崩溃 - iOS - App Crashes with compelationHandler:nil 应用程序崩溃,因为launchOptions在启动时为nil - app crashes because of the launchOptions being nil at the launch 我为聊天应用程序编写了代码,适用于 iOS 12 但在 iOS 13 中,它返回 nil 值 - I have written code for chat application, works fine for iOS 12 but in iOS 13, it return nil value iOS 9键盘:此应用程序正在从后台线程修改autolayout引擎,这可能导致引擎损坏和奇怪的崩溃 - iOS 9 keyboard: This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes iOS9此应用程序正在从后台线程修改autolayout引擎,这可能导致引擎损坏和奇怪的崩溃 - iOS9 This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM