目前很多游戏在iPhone X手机 wifi情况下,启动时候闪退,在4G网络时候不闪退。
闪退的log:
#0 Thread
NSUnknownKeyException
[<UIStatusBar_Modern 0x15f906160> valueForUndefinedKey:]: this class is not key value coding-compliant for the key foregroundView.
这是项目中使用状态栏中图标判断当前网络的具体状态,而 iPhone X手机状态栏和其他版本手机存在差异,状态栏是多嵌套了一层,所以在读取时候需要注意。
可以在代码里面搜索 foregroundView 这个关键字,找到位置进行必要修改。
NSArray *children;
// 不能用 [[self deviceVersion] isEqualToString:@"iPhone X"] 来判断,因为模拟器不会返回 iPhone X
if ([[application valueForKeyPath:@"_statusBar"] isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {
children = [[[[application valueForKeyPath:@"_statusBar"] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
} else {
children = [[[application valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
}