前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IOS13的详细适配

IOS13的详细适配

作者头像
honey缘木鱼
发布2019-10-23 15:32:23
3.3K0
发布2019-10-23 15:32:23
举报
文章被收录于专栏:娱乐心理测试
  1. 在iOS13中发现presentViewController和之前弹出的样式不一样 显示如下图

屏幕快照 2019-10-21 上午11.01.50.png 原因: 在iOS13中modalPresentationStyle的默认改为UIModalPresentationAutomatic,而在之前默认是UIModalPresentationFullScreen。

代码语言:javascript
复制
/*
 Defines the presentation style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter.
 If this property has been set to UIModalPresentationAutomatic, reading it will always return a concrete presentation style. By default UIViewController resolves UIModalPresentationAutomatic to UIModalPresentationPageSheet, but other system-provided view controllers may resolve UIModalPresentationAutomatic to other concrete presentation styles.
 Defaults to UIModalPresentationAutomatic on iOS starting in iOS 13.0, and UIModalPresentationFullScreen on previous versions. Defaults to UIModalPresentationFullScreen on all other platforms.
 */
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle API_AVAILABLE(ios(3.2));

解决方案:

代码语言:javascript
复制
    LoginViewController *vc=[[LoginViewController alloc]init];
    vc.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:vc animated:YES completion:^{}];
  1. IOS13使用 [textField setValue:placecolor forKeyPath:@"_placeholderLabel.textColor"]或者 [textField setValue:placeFont forKeyPath:@"_placeholderLabel.font"]页面奔溃。

奔溃截图

原因:iOS不允许valueForKey、setValue: forKey获取和设置私有属性。

解决方案:

代码语言:javascript
复制
     NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:placeHolder attributes:@{NSForegroundColorAttributeName : RGB(153, 153, 153)}];
     textField.attributedPlaceholder = placeholderString;
  1. UIStatusBarStyleDefault在IOS13下字体颜色变成白色。 原因:在iOS13之前有两种状态:UIStatusBarStyleDefault(黑字)、UIStatusBarStyleLightContent(白字)。 在iOS13改为三种状态:UIStatusBarStyleDefault(自动选择黑字or白字)、UIStatusBarStyleDarkContent(黑字)、UIStatusBarStyleLightContent(白字)因为IOS13在黑暗模式下,UIView默认背景色会变成暗黑色,所以UIStatusBarStyleDefault自动选择了白字。

解决方案:

代码语言:javascript
复制
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    if(@available(iOS 13.0, *)){
            [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
    }
  1. UITextFiled UITableView UIAlertController等控件莫名其妙的就变黑了

原因:iOS13使用暗黑模式时,UIView默认背景色会变成暗黑色。 解决方案:每个UIView都做修改是不现实的,统一的实现方式为: 在plist文件中增加配置项UIUserInterfaceStyle,值为UIUserInterfaceStyleLight。

5.KVC获取状态栏(_statusBar)会导致崩溃,目的是为更改状态栏背景色

原因:

代码语言:javascript
复制
   UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

解决方案:

代码语言:javascript
复制
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    UIView *viewStatusColorBlend = [[UIView alloc]initWithFrame:keyWindow.windowScene.statusBarManager.statusBarFrame];
    viewStatusColorBlend.backgroundColor = Color;
    [keyWindow addSubview:viewStatusColorBlend];

6.iOS 13 DeviceToken有变化 原因:

代码语言:javascript
复制
NSString *token = [deviceToken description];
token = [token stringByReplacingOccurrencesOfString: @"<" withString: @""];
token = [token stringByReplacingOccurrencesOfString: @">" withString: @""];
token = [token stringByReplacingOccurrencesOfString: @" " withString: @""];
这段代码运行在 iOS 13 上已经无法获取到准确的DeviceToken字符串了,iOS 13 通过[deviceToken description]获取到的内容已经变了。

解决方案:

代码语言:javascript
复制
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    if (![deviceToken isKindOfClass:[NSData class]]) return;
    const unsigned *tokenBytes = [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.ios 13蓝牙权限更新 原因:上传App Store时,如果引用了CoreBluetooth.framework,则需要添加描述配置NSBluetoothAlwaysUsageDescription,否则无法提交。

解决方案: 在plist文件中增加配置项NSBluetoothAlwaysUsageDescription。

8.通过kvc获取获取searchBar中的TextField方法更改,会引起崩溃 原因: ios13之后把SearchBar中的textField直接暴露给开发者使用,无需在通过kvc获取。 解决方案:

代码语言:javascript
复制
 UITextField * searchField = nil;
    if (@available(iOS 13.0, *)) {
        searchField =searchBar.searchTextField;
    }else {
        searchField = [searchBar valueForKey:@"_searchField"];
    }
    NSMutableAttributedString *arrStr = [[NSMutableAttributedString alloc] initWithString:searchField.placeholder attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor colorWithHex:@"#999999"]}];
    searchField.attributedPlaceholder = arrStr;
  1. 彻底废弃UISearchDisplayController、MPMoviePlayerController 原因: Xcode11编译的安装包使用UISearchDisplayController和MPMoviePlayerController时会崩溃. 解决方案: 1、使用UISearchController替代UISearchDisplayController 2、检查工程中是否有使用MPMoviePlayerController

10.UISegmentedControl 默认样式改变 默认样式变为白底黑字,如果设置修改过颜色的话,页面需要修改。 11.Sign in with Apple 第三方登录 当 Sign In with Apple 服务正式上线以后,所有已接入其它第三方登录的 App,就必须支持苹果登录。

  1. 将LaunchImage的使用放弃。 原因:因为使用LaunchImage来设置启动图,要求我们必须提供各种屏幕尺寸的启动图,来适配各种设备,相对而言比较麻烦,使用 LaunchScreen的话,情况会变的很简单。从2020年4月开始,所有使⽤ iOS13 SDK的 App将必须提供 LaunchScreen,LaunchImage即将退出历史舞台。可以使用Launch Storyboards来进行解决。
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019.10.21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档