Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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
在Swift Alert中的两个视图之间设置间隙_Swift_Uialertview - Fatal编程技术网

在Swift Alert中的两个视图之间设置间隙

在Swift Alert中的两个视图之间设置间隙,swift,uialertview,Swift,Uialertview,我创建了带有两个文本字段的警报视图,供用户输入详细信息。警报视图以编程方式生成,如下所示。有没有办法在两个文本字段之间留出一个间隙 let alertController = UIAlertController(title: "Register", message: "", preferredStyle: .Alert) alertController.addAction(OKAction) alertController.addTextFieldWithConfigurationHand

我创建了带有两个文本字段的警报视图,供用户输入详细信息。警报视图以编程方式生成,如下所示。有没有办法在两个文本字段之间留出一个间隙

 let alertController = UIAlertController(title: "Register", message: "", preferredStyle: .Alert)

alertController.addAction(OKAction)

alertController.addTextFieldWithConfigurationHandler { (textField) in
    textField.placeholder = "Name"
    textField.keyboardType = .EmailAddress
}

alertController.addTextFieldWithConfigurationHandler { (textField) in
    textField.placeholder = "Email"
    textField.secureTextEntry = false
}

alertController.addTextFieldWithConfigurationHandler { (textField) in
    textField.placeholder = "Company"
    textField.secureTextEntry = false
}


        self.presentViewController(alertController, animated: true) {
            // ...
        }

我可以给你推荐一个更好的方法。 创建自定义xib文件并使用“当前视图控制器”创建警报框,如下所示

 let vc = CustomAlertViewController()
    self.presentViewController(vc, animated: true, completion: nil)
你可以参考以下回购协议

为什么不使用模态视图控制器来执行此操作?更简单。你能解释一下吗?你正在尝试在警报视图中创建表单。警报视图有利于确认,为此创建一个视图控制器并以模式显示。你必须有更多的灵活性。