iOS14iOS14内容系统新特性

iOS14适配相关

2020-08-27  本文已影响0人  哈啰于先生

1.UITableViewCell 的 contentView 会置于自定义控件的上层。

在 iOS14 beta 中,UITableViewCell 中如果有直接添加在 cell 上的控件,也就是使用 [self addSubview:] 方式添加的控件,会显示在 contentView 的下层。
contentView 会阻挡事件交互,使所有事件都响应 tableView:didSelectRowAtIndexPath:方法,如果 customView 存在交互事件将无法响应。如果 contentView 设置了背景色,还会影响界面显示。
此改动在官方文档中并未说明,存在正式版发布时作为 bug 修复的可能性。但是在此前关于 contentView 的声明注释中,官方已经明确建议开发者将 customView 放在 contentView 上,使 contentView 作为 UITableViewCell 默认的 superView。

// Custom subviews should be added to the content view.
@property (nonatomic, readonly, strong) UIView *contentView;

2.UIDatePicker 更新 UI 样式

iOS 14 中,UIDatePicker UI样式更新了

UIDatePickerStyleInline API_AVAILABLE(ios(14.0)) API_UNAVAILABLE(tvos, watchos),
iOS14默认弹出样式 inline样式点击日期后效果

并且为默认样式。如果想使用原来的播轮样式,需要设置。

 pickerView.preferredDatePickerStyle = UIDatePickerStyleWheels;

preferredDatePickerStyle 为 iOS 13.4 新增属性

修改完后成为之前的样式


好运原始样式

3、地理位置

在 iOS13 及以前,App 请求用户定位授权时为如下形态:一旦用户同意应用获取定位信息,当前应用就可以获取到用户的精确定位。


位置授权对比(左侧:iOS13,右侧: iOS14)
 @available(iOS 14.0, *)
 open var accuracyAuthorization: CLAccuracyAuthorization { get }
public enum CLAccuracyAuthorization : Int {
    case fullAccuracy = 0
    case reducedAccuracy = 1
}

模糊定位 误差大约5km/时间误差大约20分钟。

///官方描述
Location estimates will have a horizontalAccuracy on the order of about 5km
///官方描述
Applications should be prepared to receive locations that are up to 20 minutes old.
@available(iOS 14.0, *)
open func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String, completion: ((Error?) -> Void)? = nil)

@available(iOS 14.0, *)
open func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String)

前提是在info.plist文件中设置NSLocationTemporaryUsageDescriptionDictionary(位置临时使用描述),其中purposeKeyrequestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String)方法中的参数purposeKey对应。

<key>NSLocationTemporaryUsageDescriptionDictionary</key>
 <dict>
 <key> purposeKey </key>
 <string>This app needs accurate location so it can verify that you're in a supported region. </string>
 <key> AnotherPurposeKey </key>
 <string>This app needs accurate location so it can show you relevant results.</string>
</dict>

这样app会获取到临时的精确位置权限直至下次冷启动。当然这个授权也可能被用户无情拒绝。

iOS14临时获取精准位置权限
@available(iOS 14.0, *)
public let kCLLocationAccuracyReduced: CLLocationAccuracy

如果将CLLocationManager的desiredAccuracy属性设置为该值,则为响应startUpdatingLocation或requestLocation而传递给代理的位置的精度将降低。您收到的位置将与您的应用程序收到的位置相匹配,前提是用户决定不授予您的应用程序的精确位置授权

4、相册权限

iOS14 新增了Limited Photo Library Access 模式,在授权弹窗中增加了 Select Photo 选项。用户可以在 App 请求调用相册时选择部分照片让 App 读取。从 App 的视⻆来看,你的相册里就只有这几张照片,App 无法得知其它照片的存在。

5、剪切板

上一篇 下一篇

猜你喜欢

热点阅读