iOS 13适配

iOS13 beta版本已经发布,手痒的升级Xcode和iOS,同时也发现了一些问题,这里更新下。。。

KVC

iOS13不能通过KVC的方式随意修改一些没有暴露出来的属性了。

TextField_placeholderLabel.textColor很UISearchBar的_searchField会报如下类似的错误

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'

statusBar

通过以下方式获取statusBar的方式已经不可取了,iOS13上继续使用会造成crash。

UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

报错信息如下:

reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'

替代方式为UIWindowScene的statusBarManager对象

presentViewController

iOS 13 的 presentViewController 默认有视差效果,模态出来的界面现在默认都下滑返回。 一些页面必须要点确认才能消失的,需要适配。如果项目中页面高度全部是屏幕尺寸,那么多出来的导航高度会出现问题。

需要设置一下modalPresentationStyle

viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;

我这里通过hook方法:presentViewController:animated:completion:实现全局修改

@implementation UIViewController (ChangeUI)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        swizzling_exchangeMethod([self class], @selector(presentViewController:animated:completion:), @selector(myPresentViewController:animated:completion:));
    });
}

- (void)myPresentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
    //设置满屏,不需要小卡片
    if(@available(iOS 13.0, *)) {
        viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
    }
    [self myPresentViewController:viewControllerToPresent animated:flag completion:completion];
}

CNCopyCurrentNetworkInfo变化

iOS13下不能正常获取到WiFi的ssid,需要用户开启定位权限或者使用新的API NEHotspotConfiguration获取

黑暗模式

Apps on iOS 13 are expected to support dark mode
Use system colors and materials
Create your own dynamic colors and images Leverage flexible infrastructure

第三方登录

苹果更新的审核规范中提到使用第三方登录的APP必须要将apple登录作为一个可选择项

Sign In with Apple will be available for beta testing this summer. It will be required as an option for users in apps that support third-party sign-in when it is commercially available later this year.

后续其他iOS13适配问题继续更新。。。。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在简书偶尔会被锁定,本文在掘金也同步更新。 iOS 13 支持适配的机型 iPhone 11、iPhone 11 ...
    _森宇_阅读 13,188评论 2 37
  • 私有KVC 与系统版本无关,与Xcode版本有关,Xcode11编译会奔溃。 其中UITextField [tex...
    Kity_Pei阅读 15,747评论 12 13
  • iOS 13 如期而至,适配工作可以开展起来啦。在适配 iOS 13 过程中,遇到了如下一些问题。 1. UITe...
    前行哲阅读 20,350评论 48 136
  • iOS 13 马上就要来了,各位 iOS 开发的小伙伴们,iOS 13 beta版的适配工作可以做起来了,O(∩_...
    林神_iOS阅读 9,800评论 2 20
  • 文‖云飞扬 插一把艾草的清香 在端午的门楣思念 献上粽子、香囊 手腕系五彩的丝线 用一首《楚辞》 在为谁人打起的经...
    山东云飞扬阅读 1,605评论 1 2