美文网首页
iOS14适配

iOS14适配

作者: 伶俐ll | 来源:发表于2020-11-03 10:23 被阅读0次

1、 UIPageControl 的 pageImage

KVC 不允许访问 UIPageControl的pageImage,例如下面这样:

[pageControl setValue:[UIImage imageNamed:@"image1"] forKeyPath:@"_pageImage"];`
[pageControl setValue:[UIImage imageNamed:@"image2"] forKeyPath:@"_currentPageImage"];

程序内有的话,必须删除一下,具体操作在工程内搜索"_pageImage"和@"currentPageImage"关键字,找到对应代码并删除。

新增了API:preferredIndicatorImage设置image

2、UIDatePicker

iOS 14引入了一个全新的日期选择器样式

iOS 14 中的 UIDatePicker新增了 datePickerStyle的属性,并且默认是UIDatePickerStyleAutomatic样式,系统自动为当前平台和模式选择的可用的最佳样式

/// Automatically pick the best style available for the current platform & mode.
  UIDatePickerStyleAutomatic,
 /// Use the wheels (UIPickerView) style. Editing occurs inline.
  UIDatePickerStyleWheels,
 /// Use a compact style for the date picker. Editing occurs in an overlay.
  UIDatePickerStyleCompact,
   /// Use a style for the date picker that allows editing in place.
  UIDatePickerStyleInline API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(tvos, watchos),

具体样式,可以进入New UIDatePicker in iOS 14 @Andy lbanez,查看

适配:如果在iOS14不想采用最新样式,可以设置preferredDatePickerStyleUIDatePickerStyleWheels,这是我们最熟悉的样式。
if (@available(iOS 13.4, *)) {
      datePicker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}

3、UITableViewCell

iOS14推荐使用[cell.contentView addSubview:];方式添加控件。

因为UITableViewCell中使用 [cell addSubview:]方式添加的控件,会显示在contentView的下层,控件会被contentView遮挡并无法响应交互事件。

4、隐私适配

这篇文章总结的挺好的; https://www.jianshu.com/p/1803bd950b90

idfa

iOS14中,系统会默认为用户 关闭 广告追踪权限,且之前判断用户是否允许被追踪的方法被废弃
iOS14系统IDFA配置

  1. 首先在 info.plist 中配置权限:
    key:NSUserTrackingUsageDescription
    value:获取设备信息用以精准推送您喜欢的内容
  2. 通过以下代码获得IDFA标识符:
#import <AdSupport/AdSupport.h>
#import <AppTrackingTransparency/AppTrackingTransparency.h>
 
- (void)getIDFA {
    // iOS14方式访问 IDFA
    if (@available(iOS 14, *)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                NSString *idfaStr = [[ASIdentifierManager sharedManager] advertisingIdentifier].UUIDString;
                NSLog(@"idfaStr - %@", idfaStr);
            }
        }];
    } else {
        // 使用原方式访问 IDFA
        if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
            NSString *idfaStr = [[ASIdentifierManager sharedManager] advertisingIdentifier].UUIDString;
            NSLog(@"idfaStr - %@", idfaStr);
        }
    }
}
粘贴板问题
定位方面
相册

相关文章

网友评论

      本文标题:iOS14适配

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