UIAlertController TextField 中不需要的顶部 space

Unwanted top space in UIAlertController TextField

我正在尝试创建一个对话框来询问要保存的文件名。

不知何故,显示的文本字段上面有一个额外的 space,我无法将其删除。 space 不可用(它不是一条线,只是一个上边距)

我什至尝试更改文本字段的 .frame.height 属性 也无法摆脱它。

请帮忙!我不明白为什么会这样?

屏幕截图:http://i.stack.imgur.com/dQYjz.png

密码是:

    var fieldSetListName: UITextField!

    func askForSetListName() {

    //Create the AlertController
    let alertController: UIAlertController = UIAlertController(title: "Name", message: "Enter a name for Setlist", preferredStyle: .Alert)

    //Create and add the Cancel action
    let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
        //Do some stuff
    }
    alertController.addAction(cancelAction)

    //Create and an option action
    let okAction: UIAlertAction = UIAlertAction(title: "OK", style: .Default) { action -> Void in
    //Do some other stuff
    self.saveSetListAndDismiss(self.fieldSetListName.text)
    }

    alertController.addAction(okAction)
    //Add a text field
    alertController.addTextFieldWithConfigurationHandler { textField -> Void in
    textField.textColor = UIPalette.DarkText
    textField.placeholder = "(venue, festival, date etc.)"
    self.fieldSetListName = textField
    }

    //Present the AlertController
    self.presentViewController(alertController, animated: true, completion: nil)
    }

像这样添加文本字段:

 var example :UITextField
 var inputText : String
 let exampletextField = actionSheetController.textFields![0] as UITextField
 exampletextField.textColor = UIPalette.DarkText
 exampletextField.placeholder = "(venue, festival, date etc.)"
 inputText = exampletextField.text

找到解决方案。

对于遇到此类问题的任何人,使用 UIAppearance 全局设置 UITableView 的 rowHeight 属性 会影响 alertview 内的文本字段高度:

我去掉了这一行:UITableView.appearance().rowHeight = 50