我正在尝试创建一个对话框,要求保存文件名。
不知何故,显示的文本字段上面有一个额外的空格,我无法将其删除。空间不可用(它不是一条线,只是一个上边距)
即使尝试更改文本字段的.frame.height属性,我也无法摆脱它。
请帮忙!我不明白为什么会这样?
ScreenShot: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)
}
答案 0 :(得分:0)
像这样添加textField:
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
答案 1 :(得分:0)
找到了解决方案。
对于遇到此类问题的任何人,使用UIAppearance全局设置UITableView的rowHeight属性会影响alertview内的文本字段高度:
我摆脱了这条线:UITableView.appearance()。rowHeight = 50