ios - UIAlertAction 按钮不仅仅出现在 iPhone 6s (iOS 14.4)
问题描述
UIAlertController 的标题出现了,但 UIAlertAction 按钮不仅出现在 iPhone 6s 中。请帮我解决这个问题。
以下是我尝试过的代码:
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)
解决方案
推荐阅读
- typescript - TS 中的函数签名确实允许附加属性
- python - 条目在一年内至少两个不同的月份出现在每个索引中
- c - 如何使用 NASM 修改某些 C 指针指向的内存?
- ios - 可以在不暴露其他 xcframeworks 的依赖关系的情况下提供和 xcframework 吗?
- tableau-api - 有没有办法在粒度级别对不同的数字进行计数,以在画面中聚合多个条件?
- react-native - React Native FlatList 不显示任何内容
- gpu - 检查失败:status == CUDNN_STATUS_SUCCESS (7 vs. 0)Failed to set cuDNN stream
- python - 如何在数组支持的网格上实现 Q-Learning?
- tensorflow - 如何在 PyTorch 中实现的 keras 或 tensorflow 中翻译 conv2D?
- javascript - 事件单击显示具有 FullCalendar 功能的选定数据