无法弄清楚为什么Xcode模拟器无法正常工作

时间:2017-04-26 03:33:18

标签: ios swift xcode

screenshot of the story board我是一名新学生,在Udemy.com学习快速开发ios。我按照其中一个例子来创建一个按钮,可以将屏幕颜色从白色变为红色;但是,我不明白为什么ios模拟器没有告诉我想要发生什么。相反,它只是让我看到一个黑屏。先谢谢你。screenshot of the ios simulator after launched

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.



}

@IBOutlet weak var myBotton: UIButton!

@IBAction func MyBottonClicked(_ sender: UIButton) {
    self.view.backgroundColor = UIColor.red
}

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

2 个答案:

答案 0 :(得分:0)

清理项目并再次运行 在xcode命令+ shift + k

答案 1 :(得分:0)

我认为模拟器没有问题,您在连接插座或操作时遇到问题。确保您的插座或操作已连接到故事板中的视图。

您需要注意的另一件事是为故事板设置入口点。由于这些原因,你提到的黑色屏幕

enter image description here