1.UIDatePicker
UIDatePicker 在 13.4 新增了2个属性如下
/// Request a style for the date picker. If the style changed, then the date picker may need to be resized and will generate a layout pass to display correctly.
@property (nonatomic, readwrite, assign) UIDatePickerStyle preferredDatePickerStyle API_AVAILABLE(ios(13.4)) API_UNAVAILABLE(tvos, watchos);
/// The style that the date picker is using for its layout. This property always returns a concrete style (never automatic).
@property (nonatomic, readonly, assign) UIDatePickerStyle datePickerStyle API_AVAILABLE(ios(13.4)) API_UNAVAILABLE(tvos, watchos);
typedef NS_ENUM(NSInteger, UIDatePickerStyle) {
/// 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),
} API_AVAILABLE(ios(13.4)) API_UNAVAILABLE(tvos, watchos);
原来的界面选择器样式就变成新的样式,布局也发生比较大的改变,要变成原来的样式,需添加如下代码
//_datePicker.backgroundColor = [UIColor whiteColor]; 背景色是透明的。
if (@available(iOS 13.4, *)) {
_datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//新发现这里不会根据系统的语言变了
_datePicker.preferredDatePickerStyle = UIDatePickerStyleWheels;
} else {
// Fallback on earlier versions
}
根据项目中的界面样式,发现了2个问题,
1.UIDatePicker 设置背景色没有用了,是透明的。
2.语言不会根据系统语言变化了,要自己设置为中文。
3.需要在preferredDatePickerStyle = UIDatePickerStyleWheels;
之后重新设置frame
2.Cell点击无效
在iOS14上可能出现点击cell上的视图无法响应的情况.
原因:
iOS14更改Cell视图布局.将contentView放在最上层,如果将视图加载在cell上,将会出现contentView遮罩,导致事件无法响应.是在此前关于 contentView 的声明注释中,官方已经明确建议开发者将 customView 放在 contentView 上,使 contentView 作为 UITableViewCell 默认的父视图。
解决办法:
1、可以将cell子视图加载在contentView上(提倡)
2、将contentView设置到最底层 self.sendSubviewToBack(self.contentView)
未完待续.....