我試圖實現一個簡單的步進器,它將其值反映到標籤上。 在使用「INT(sender.value)」我得到一個錯誤「不明確的利用價值」在實現UIStepper時模糊使用「值」
// ViewController.swift
// Stepper
//
// Created by Prabhu Konchada on 19/06/15.
// Copyright (c) 2015 Prabhu. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var StepperValue: UILabel!
@IBOutlet weak var OutputLabel: UILabel!
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 StepperTap(sender: AnyObject) {
self.OutputLabel.text = String(Int(sender.value).description)
}
}
爲什麼你要將值轉換爲Int? –
@AshishKakkad我厭倦了沒有它,它成功構建,但引發此錯誤0x1947e2a08) libC++ abi.dylib:終止與未捕獲異常類型NSException (lldb)。所以我遵循這個教程http://www.ioscreator.com/tutorials/uistepper-tutorial-ios8-swift –
@AshishKakkad我認爲問題是使用AnyObject而不是發件人:) –