【发布时间】:2018-05-02 19:44:20
【问题描述】:
我有在应用程序中运行历史记录的代码。
如何改进它,以便在按下时立即显示数字,而不仅仅是按下 =?
我的程序:
// Connected to button "="
@IBAction func equalitySignPressed(sender: UIButton) {
if stillTyping {
secondOperand = currentInput
}
dotIsPlaced = false
addHistory(text: operationSign + displayResultLabel.text!)
switch operationSign {
case "+":
operateWithTwoOperands{$0 + $1}
case "-":
operateWithTwoOperands{$0 - $1}
case "×":
operateWithTwoOperands{$0 * $1}
case "÷":
operateWithTwoOperands{$0 / $1}
default: break
}
}
func addHistory(text: String){
//Add text
resultLabelText.text = resultLabelText.text! + "" + text
}
电流输出:
【问题讨论】:
标签: ios swift uibutton ibaction