我的代碼成功生成,但顯示錯誤如何改變的UIImageView的形象:基於UISwitch的狀態
2017-01-25 14:05:06.645 project 4[2500:109254] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imagechg.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myImageView: UIImageView!
@IBOutlet weak var switchController: UISwitch!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func segmentChanged(_ sender: UISegmentedControl) {
print(sender.selectedSegmentIndex)
}
@IBAction func switchimgchng(_ sender: UISwitch) {
if switchController.isOn == true {
myImageView.image = UIImage(named: "appleBlack.png")
}
}
}
你的錯誤日誌錯誤在哪裏????????? – karthikeyan
2017-01-25 14:05:06.645項目4 [2500:109254] ***由於未捕獲異常'NSUnknownKeyException',原因:'[ setValue:forUndefinedKey:]:此類爲而不是關鍵的imagechg編碼密鑰值。「 –
sdp
@sdp編輯你的文章和它的錯誤請:) – goto