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)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...