iOS 13 适配(持续更新)

作者: 林神_iOS | 来源:发表于2019-08-13 14:09 被阅读89次

iOS 13 马上就要来了,各位 iOS 开发的小伙伴们,iOS 13 beta版的适配工作可以做起来了,O(∩_∩)O哈哈~,不多废话,直入主题!

Xcode 11 beta 版下载地址:https://developer.apple.com/download/

iOS 13 手机系统下载方式,可以用描述文件下载,但是该方法无法降级,建议用爱思助手,可以方便系统升降级;

1.CNCopyCurrentNetworkInfo 方法,获取不到当前连接的WiFi信息

如果想要获取当前手机连接的WiFi,肯定需要调用该方法,iOS 13之前用该方法获取没问题,iOS 13再用该方法就获取不到了;那是什么原因呢?是有新方法嘛?还是说这事iOS 13beta版的bug;显然不是:查阅官网才发现:获取不到WiFi是因为,需要获取当前定位信息(之前以为只有Android需要这么做,现在iOS也加了这个条件);官网地址:https://forums.developer.apple.com/thread/117371;

可以看出在这三个条件下,CNCopyCurrentNetworkInfo这个方法才可以获取到当前连接WiFi信息;

参考代码:


2.KVC 限制

[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];

调用该方法会导致xcode崩溃,iOS 13上可以正常运行,但是用xcode跑会crash,报错信息:

'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'

修改方案:

textField.attributedPlaceholder = [[NSAttributedStringalloc] initWithString:@""attributes:@{NSForegroundColorAttributeName:[UIColor red]}];


3.UISegmentedControl 颜色设置方式改变

iOS 13之前设置 tintColor 的方式,已经没法改变UISegmentedControl的背景色,可通过以下方法改变:

_segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"one", @"two"]];

[_segmentedControl setBackgroundImage:[vUtilityAPP imageWithColor:[UIColor blueColor]] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

[_segmentedControl setBackgroundImage:[vUtilityAPP imageWithColor:[UIColor redColor]] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

4.iOS 13中 presentViewController 模态动画,跳转问题修复

iOS 13之前 presentViewController 跳转的 modalPresentationStyle 默认为 UIModalPresentationFullScreen ;

在iOS 13中默认 style 被改为 UIModalPresentationAutomatic,可参考苹果代码注释:

修改方案:

CLBaseWebViewController *webViewController = [[CLBaseWebViewController alloc] initWithURL:url type:type data:data];

UINavigationController *nav = [[UINavigationControlleralloc] initWithRootViewController:webViewController];

nav.modalPresentationStyle = UIModalPresentationFullScreen;

[self.navigationController presentViewController:nav animated:YES completion:nil];

即:将 vc.modalPresentationStyle 的值改为 UIModalPresentationFullScreen ;

5.UITableView的accessoryType为UITableViewCellAccessoryDisclosureIndicator时,显示会有问题;

iOS 13设置该值时会显示:

需要更换为自定义的箭头图片;

6.[deviceToken description] 获取到的格式发生变化

iOS 13正确获取Devicetoken代码:

#include <arpa/inet.h>

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

{

    if (![deviceToken isKindOfClass:[NSData class]]) return;

    const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];

    NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",

                          ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),

                          ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),

                          ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];

    NSLog(@"deviceToken:%@",hexToken);

}

7.App启动过程中,部分View可能无法实时获取到frame

// 只有等执行完 UIViewController 的 viewDidAppear 方法以后,才能获取到正确的值,在viewDidLoad等地方 frame Size 为 0,例如:

[[UIApplication sharedApplication] statusBarFrame];

8.适配深夜模式

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

在iOS 13设备上,苹果要求适配深夜模式,适配该模式的时候,本来想自己写一个较详细的,但是已经看到一个小伙伴写的很不错了,就直接拿过来啦,哈哈

参考地址:https://juejin.im/post/5cf6276be51d455a68490b26

9.UISearchBar

UISearchBar主要还是KVC获取系统私有属性,导致的坑,自己这边项目中没用到,但是有很多小伙伴遇到了,就一起记录下:

参考地址 :http://yoferzhang.com/post/20190604Searchbarios13/

相关文章

  • iOS13 适配问题 看这一篇就够了

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • iOS 13适配

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • iOS13适配

    参考: iOS13 适配踩坑 - 持续更新 iOS 13 适配要点总结 iOS 13 适配要点总结 1、prese...

  • iOS 13 适配(持续更新)

    iOS 13 马上就要来了,各位 iOS 开发的小伙伴们,iOS 13 beta版的适配工作可以做起来了,O(∩_...

  • Xcode10和iOS12适配

    原文Xcode10和iOS12适配Xcode10和iOS12适配(持续更新)适配iPhoneX全系详解,更新Xco...

  • iOS 13 适配

    随着苹果发布会的开展,iOS 13 也随之而来,又来适配的 work 了,后续会持续更新,欢迎大家发现关于适配的问...

  • iOS 13 适配(持续更新中)

    私有KVC 与系统版本无关,与Xcode版本有关,Xcode11编译会奔溃。 其中UITextField [tex...

  • iOS 13 适配要点总结(转)

    转自: iOS 13 适配要点总结 iOS 13适配

  • 暗黑模式开发

    iOS13暗黑模式适配(项目开发版) iOS 13 DarkMode 暗黑模式 IOS 暗黑模式适配---基础适配

  • iOS之iOS13适配总结

    前言 随便iOS开发开始更新变成Xcode11,适配iOS13变成了现在的当务之急。 新特性适配 一、新添加的Da...

网友评论

    本文标题:iOS 13 适配(持续更新)

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