iOS12适配及问题记录

本文记录了在iOS12上遇到的适配问题,包括StatusBar内部结构改变导致的crash、[UIImage imageNamed:]加载Assets图片失效、iPhone X系列刘海屏WKWebView适配问题,以及iOS12.0.x的serviceSubscriberCellularProviders Crash。提供了详细的解决方法。
摘要由CSDN通过智能技术生成

iOS12适配及问题记录

版本信息

Xcode: Version 10.0 beta (10L176w)
macOS: 10.14 Beta (18A293u)
iOS: 12.0(16A5288q)

问题及解决过程

1,StatusBar内部结构改变

现象:crash

crash log:

-[_UIStatusBarIdentifier isEqualToString:]: unrecognized selector sent to instance 0x283452820

*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[_UIStatusBarIdentifier isEqualToString:]: unrecognized selector sent to instance 0x283452820’

—————————————————————————————————————————————————————

问题代码和解决方法


+ (NSString *)getIphoneXNetWorkStates {    
    UIApplication *app = [UIApplication sharedApplication];
    id statusBar = [[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"statusBar"];
    id one = [statusBar valueForKeyPath:@"regions"];
    id two = [one valueForKeyPath:@"trailing"];
    NSArray *three = [two valueForKeyPath:@"displayItems"];
    NSString *state = @"无网络";
    for (UIView *view in three) {
        //alert: iOS12.0 情况下identifier的变成了类"_UIStatusBarIdentifier"而不是NSString,所以会在调用“isEqualToString”方法时发生crash,
        //修改前
//        NSString *identifier = [view valueForKeyPath:@"identifier"];
        //修改后
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值