iPhone X 游戏闪退:NSUnknownKeyException


         目前很多游戏在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];  
} 

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM