Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UIAlertAction按钮不仅出现在iPhone 6s(iOS 14.4)中_Ios_Swift_Swift5_Uialertaction - Fatal编程技术网

UIAlertAction按钮不仅出现在iPhone 6s(iOS 14.4)中

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

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)
来自Apple的:UIAlertController类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改。-您应该创建自己的日期选择器视图控制器并显示它。