2016-08-01 37 views
-4

我无法将Int的变量分配给UILabel,我该如何解决这个问题?无法将Int的变量分配给UILabel

进口的UIKit

类的ViewController:UIViewController的{

@IBOutlet var CoinCounterInt: UILabel! 
@IBOutlet weak var CoinCounter: UILabel! 
var coins = 0 
override func viewDidLoad() { 
    super.viewDidLoad() 
    // Do any additional setup after loading the view, typically from a nib. 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 


@IBAction func Clicker(sender: AnyObject) { 
    coins += 1 
    CoinCounterInt = "\(coins)" 
} 

}

回答

1

您需要将字符串分配到标签的Text属性:
CoinCounterInt.text = "\(coins)"

+1

@NilsGarland我猜是因为你没有看太多。 –

相关问题