悄然而来的iOS14,没有罗列太多.在这里我们稍微了解一下需要做的更新.
适配1: Cell点击无效
在14上可能出现点击cell上的视图无法响应的情况.
原因:iOS14更改Cell视图布局.将contentView放在最上层,如果将视图加载在cell上,将会出现contentView遮罩,导致事件无法响应.是在此前关于 contentView 的声明注释中,官方已经明确建议开发者将 customView 放在 contentView 上,使 contentView 作为 UITableViewCell 默认的 fatherView。
解决办法:
1、可以将cell子视图加载在contentView上(提倡)
2、将contentView设置到最底层 self.sendSubviewToBack(self.contentView)
适配2:UIDatePicker 更新 UI 样式
iOS 14 中,UIDatePicker UI样式更新了
适配3:相册权限
iOS14 新增了“Limited Photo Library Access” 模式,在授权弹窗中增加了 Select Photo 选项。用户可以在 App 请求调用相册时选择部分照片让 App 读取。从 App 的视⻆来看,你的相册里就只有这几张照片,App 无法得知其它照片的存在。
重点!!!:权限提示框会在每次冷启动后打开相册时重新弹出,可以在 info.plist 中设置 PHPhotoLibraryPreventAutomaticLimitedAccessAlert 选项为 YES ,关闭提示
适配4:地理位置
新增了 精确定位 和 模糊定位 的概念,用户可以手动选择,模糊定位的误差约 500m 。可以根据实际功能判断是否可以接受用户选择模糊定位。
如果功能强依赖精确定位,可以在需要的时候调用 [CALocationMnanger requestTemporaryFullAccuracyAuthorizationWithPurposeKey:] 单独请求一次精确定位,用户可以选择拒绝授权。所需参数 purposeKey 需要在 info.plist 中设置 NSLocationTemporaryUsageDescriptionDictionary 字典,key 为 purposeKey , value 为对应的话述
权限部分可以参考
5:模拟器运行提示错误
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/AFNetworking'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/FMDB'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/IQKeyboardManager'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/JQCollectionViewAlignLayout'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/MBProgressHUD'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/MJRefresh'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/Masonry'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/SDWebImage'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/TouchJSON'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/YBImageBrowser'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/YYImage'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/YYModel'
ld: warning: directory not found for option '-L/Users/conan/Library/Developer/Xcode/DerivedData/DaYi-cuupfsrvoecbukceokqclslullyu/Build/Products/Debug-iphonesimulator/YYText'
ld: warning: directory not found for option '-F/Users/conan/Documents/logistics-ios/DaYi/Lib'
ld: warning: directory not found for option '-F/Users/conan/Documents/logistics-ios/DaYi/Tools/Carmal/General/SLAnimateImageView'
ld: warning: directory not found for option '-F/Users/conan/Documents/logistics-ios/DaYi/Tools/Carmal/SLAnimateImageView'
ld: library not found for -lAFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
等等,这样的情况,很多是不支持模拟器调试.因为iOS14只支持arm64,很多三方库暂时还不支持.导致模拟器运行错误.直接采用真机调试即可.
6:图片浏览
iOS 14.0 YYAnimatedImageView 无法显示正常图片
14.0 系统调用了此方法,YYAnimatedImageView没有正确处理
(void)displayLayer:(CALayer *)layer;
解决如下
YYAnimatedImageView.m
(void)displayLayer:(CALayer *)layer {
if (_curFrame) {
layer.contents = (__bridge id)_curFrame.CGImage;
} else {
// If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering.
if ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) {
[super displayLayer:layer];
}
}
}
iOS14更新内容及兼容设备
iOS 14 兼容设备.png还有一些待完善,会持续更新下.
网友评论