应用程序的要点很简单,你按下小骰子图像,它运行一个从1-6返回一个随机数的函数,屏幕上的框反映了它在骰子上的样子,彩色框标签是掷骰子时用数字更新.当我运行应用程序时,一切都看起来很好.一旦我按下骰子按钮,randomDiceRoll()函数就会运行,但彩色框标签和UIView框(反映它在骰子上的样子)不匹配.再一次,我只是学习Swift,所以请给我一些懈怠.感谢所有贡献者!这是代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet var upperLeft: UIView!
@IBOutlet var midLeft: UIView!
@IBOutlet var lowerLeft: UIView!
@IBOutlet var middle: UIView!
@IBOutlet var upperRight: UIView!
@IBOutlet var midRight: UIView!
@IBOutlet var lowerRight: UIView!
@IBOutlet var redBox: UILabel!
@IBOutlet var orangeBox: UILabel!
@IBOutlet var yellowBox: UILabel!
@IBOutlet var greenBox: UILabel!
@IBOutlet var blueBox: UILabel!
@IBOutlet var purpleBox: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
redBox.isHidden = true
orangeBox.isHidden = true
yellowBox.isHidden = true
greenBox.isHidden = true
blueBox.isHidden = true
purpleBox.isHidden …Run Code Online (Sandbox Code Playgroud)