我的代码成功生成,但显示错误如何改变的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