我们正在使用xcode 11 beta 5中的催化剂快速将iOS应用程序转换为与macCatalyst兼容。
我们面临的问题是默认的DatePicker不在窗口中显示。
我正在尝试针对Mac的此解决方案,它将在视图中添加日期选择器,但我想要另一个合适的解决方案。还有其他建议吗?
func datepickerWillLoad() {
self.datePicker.datePickerMode = .date
self.datePicker.maximumDate = Date()
self.datePicker.backgroundColor = UIColor.Theme.lightBackground
self.datePicker.setValue(UIColor.Theme.whiteColor, forKeyPath: "textColor")
self.datePicker.addTarget(self, action: #selector(didChangedDatePickerValue), for: .valueChanged)
//if user open picker and without change click on done
self.dateOfBirthTextField.addTarget(self, action: #selector(didChangedDatePickerValue), for: .editingDidEnd)
#if targetEnvironment(macCatalyst)
datePicker.frame = CGRect(x: 0, y: self.view.frame.height - 200 , width: self.view.frame.width, height: 200)
self.view.addSubview(datePicker)
#else
self.dateOfBirthTextField.inputView = datePicker
#endif
}
我们正在使用xcode 11 beta 5中的催化剂快速将iOS应用程序转换为与macCatalyst兼容。我们面临的问题是默认DatePicker不在窗口中显示。我正在为Mac尝试此解决方案...
我发现如果我将datepicker文本颜色设置为self.datePicker.setValue(UIColor.Theme.whiteColor,forKeyPath:“ textColor”)那么这会导致应用在加载视图时崩溃。尝试删除该行代码,它应可与mac催化剂一起使用。