我是swift的新手,那么如何添加一个额外的else语句,说我的按钮大于56 &小于65?如果其他语句在Swift中
该按钮正常工作,它只需要添加一个额外的语句完成我的编码。
@IBAction func Submit4Button(sender: AnyObject) {
let a: Float? = (EnterH4Dimension.text as NSString).floatValue
if a > 65 {
self.DimensionLabel.text = " Cameron H4 With Guide Pins."
yesButton.hidden = false
noButton.hidden = false
emailButton.hidden = true
DimensionLabel.hidden = false
self.view.endEditing(true)
}
else if EnterH4Dimension.text == "" {
noButton.hidden = true
yesButton.hidden = true
var alert = UIAlertController(title: "Dimension", message: "Missing Data Input.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
else {
self.DimensionLabel.text = "Dimensions meet guideline"
noButton.hidden = true
yesButton.hidden = true
DimensionLabel.hidden = false
shallowDimButton.hidden = true
emailButton.hidden = false
self.view.endEditing(true)
}
}
否则,如果> 55 && <65 {},那我到目前为止写的,但遇到错误。 – Coder
你已经添加了一个'else if'子句......你只需要做同样的事情。无论如何,这有什么特别之处? –
@Coder现在这是一个语法错误。考虑一下。 '<'运算符需要**两个**操作数。你必须说**什么**你想少于65.'否则如果> 55 && a <65'。 –