【发布时间】:2020-05-13 02:54:48
【问题描述】:
所以我是编码新手,我想让标签在您单击同一个按钮时更改其文本。这样做是虽然你可以使用变量绑定一个 inter get out 和 if 语句,但是隐藏不起作用。代码如下:
@IBAction func buttonOne(_ sender: Any)
{
var nextText:Int = 1
nextText += 1
if nextText == 2
{
labelOne.text = "We have a developing situation."
}
if nextText == 3
{
labelOne.text = "About forty five minutes ago 15 unknown assailant broke into Chicago 1st State Bank"
}
if nextText == 4
{
labelOne.text = "They are armed and dangerous and have taken numerous hostages"
}
if nextText == 5
{
labelOne.text = "Your mission is to take you and your partner in to bank and free the hostages"
}
if nextText == 5
{
labelOne.text = "You shall enter the bank via helicopter and rappel onto the roof, good luck."
}
}
【问题讨论】:
-
将
nextText清除为类级属性