TTADataPickerView
TTADataPickerView copied to clipboard
Doesn't work on iOS 13.
Seems like this doesn't work on iOS 13. It could be due to iOS 13's new stacked modal view controllers. I am presenting from a modal view controller that has Form Sheet presentation. I tried from Full Screen and it's the same issue. Debugging the UI shows that the UIDatePicker has width and height of 0.
yes, i have same problem on iOS 13
@sherwinzadeh are you fix this problem?
@sherwinzadeh i fixed this bug, like this: `public func showPickerView(ttpickerView: TTADataPickerView, completion: (() -> Void)? = nil) {
// Get the top viewController
self.pickerView = ttpickerView
var topController = UIApplication.shared.keyWindow?.rootViewController
while (topController?.presentedViewController != nil) {
topController = topController?.presentedViewController
}
topController?.resignFirstResponder()
// Put the pickerView at the bottom of the screen
ttpickerView.frame.origin.y = view.bounds.size.height
view.addSubview(ttpickerView)
// Set this controller as a childViewController of the topController,
// Add put it's view as a subView of the topController's view
view.frame = CGRect(x: 0, y: 0, width: topController?.view.bounds.width ?? 0, height: topController?.view.bounds.height ?? 0)
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
topController?.addChildViewController(self)
topController?.view.addSubview(self.view)
if #available(iOS 13.0, *) {
self.fixDisplayBug(ttpickerView: ttpickerView)
}
// Show anmiation
UIView.animate(withDuration: 0.25, delay: 0, options: UIView.AnimationOptions.beginFromCurrentState, animations: {
self.view.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
ttpickerView.frame.origin.y = self.view.bounds.size.height - ttpickerView.frame.size.height
}) { (_) in
guard let handle = completion else { return }
handle()
}
}
private func fixDisplayBug(ttpickerView: TTADataPickerView) {
var pickerFrame = ttpickerView.pickerView?.frame
pickerFrame?.size.width = UIScreen.main.bounds.width
ttpickerView.pickerView?.frame = pickerFrame ?? CGRect.zero
var datePickerFrame = ttpickerView.datePicker?.frame
datePickerFrame?.size.width = UIScreen.main.bounds.width
ttpickerView.datePicker?.frame = datePickerFrame ?? CGRect.zero
var toolBarFrame = ttpickerView.toolBar.frame
toolBarFrame.size.width = UIScreen.main.bounds.width
ttpickerView.toolBar.frame = toolBarFrame
}`
Thanks!
didClickConfirmButton (TTADataPickerView.swift:497) crash