UIAlertAction按钮不仅出现在iPhone 6s(iOS 14.4)中
UIAlertController的标题会出现,但UIAlertAction按钮不仅仅出现在iPhone 6s中。请帮我弄清楚这件事 以下是我尝试过的代码:UIAlertAction按钮不仅出现在iPhone 6s(iOS 14.4)中,ios,swift,swift5,uialertaction,Ios,Swift,Swift5,Uialertaction,UIAlertController的标题会出现,但UIAlertAction按钮不仅仅出现在iPhone 6s中。请帮我弄清楚这件事 以下是我尝试过的代码: datePicker.frame = CGRect(x: 0, y: 50, width: 270, height: 230) let alertController = UIAlertController(title: dateSelection == DateSelection.FROM_DATE_SEL
datePicker.frame = CGRect(x: 0, y: 50, width: 270, height: 230)
let alertController = UIAlertController(title: dateSelection == DateSelection.FROM_DATE_SELECTION ? "Select date" : "To Date",
message: "\n\n\n\n\n\n\n\n", preferredStyle: .alert)
let selectAction = UIAlertAction(title: "Ok", style: .default, handler: { _ in
self.prepareDates(selectedDate: self.datePicker.date, dateSelection: dateSelection)
})
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.view.setNeedsLayout()
alertController.view.addSubview(datePicker)
alertController.addAction(selectAction)
alertController.addAction(cancelAction)
let height: NSLayoutConstraint = NSLayoutConstraint(item: alertController.view!, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: self.view.frame.height * 0.40)
alertController.view.addConstraint(height);
present(alertController, animated: true)
来自Apple的:UIAlertController类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改。-您应该创建自己的日期选择器视图控制器并显示它。