iOS 13适配

作者: 张叔叔 | 来源:发表于2019-08-28 17:18 被阅读0次

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适配

    本文链接:https://www.haomeiwen.com/subject/pbouectx.html