问题
I tried to start the project and play around with viewcontroller but I do not see it. Only appdelegate and scenedelegeate and contentview. The code below was supposed to be added to viewcontroller but I do not know where to add. It keeps giving me a error message saying unresolved identifier present and action. please help.
@IBAction func hello() {
// add alert
let alert = UIAlertController(title: "hello", message: "daaaammmmmn", preferredStyle: .alert)
let okAction = UIAlertAction(title: "ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
回答1:
When you created the project, in the User Interface pop-up, you chose SwiftUI.
Choose Storyboard instead.
来源:https://stackoverflow.com/questions/58050723/there-is-no-viewcontroller-swift-file-when-i-start-the-project