升级ios13后程序奔溃原因

奔溃原因是:使用栏状态栏中图标判断当前网络的具体状态

报以下异常:

2019-06-12 18:50:43.131762+0800 Seetong_tps[329:11201] [carrier isoCountryCode]==cn,[carrier allowsVOIP]=1,[carrier mobileCountryCode=460,[carrier mobileNetworkCode]=00,currentCountry=中国移动

2019-06-12 18:50:43.166316+0800 Seetong_tps[329:11201] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key foregroundView.'

*** First throw call stack:

(0x1a9d6e168 0x1aa27951c 0x1a9c73f20 0x1a98ff4cc 0x1a9877f78 0x1052bd7a4 0x105361260 0x1051fd10c 0x10752993c 0x10752ad18 0x10752d420 0x10753c1dc 0x10753cb04 0x1aa5b8fd4 0x1aa5bbaa4)

libc++abi.dylib: terminating with uncaught exception of type NSExceptio   

把如下代码注释即可运行

if ([[[UIApplication sharedApplication] valueForKeyPath:@"_statusBar"] isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {

        children = [[[[[UIApplication sharedApplication] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];

    }else{

        children = [[[[UIApplication sharedApplication] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];

    }

因为IOS13中的_statusBar为空了,真坑,如下图:

升级ios13后程序奔溃原因_第1张图片

你可能感兴趣的:(升级ios13后程序奔溃原因)