启动项目时没有viewcontroller.swift文件 [英] There is no viewcontroller.swift file when I start the project

查看:37
本文介绍了启动项目时没有viewcontroller.swift文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图启动该项目并使用viewcontroller进行操作,但是我看不到它.仅appdelegate,scenedelegeate和contentview.下面的代码应该被添加到viewcontroller中,但是我不知道在哪里添加.它不断给我一个错误消息,提示存在未解决的标识符和操作.请帮忙.

  @IBAction func hello(){//添加警报让alert = UIAlertController(标题:"hello",消息:"daaaammmmmn",preferredStyle:.alert)let okAction = UIAlertAction(title:"ok",样式:.default,处理程序:nil)alert.addAction(动作)目前(警告,动画:是,完成:无)} 

改为选择情节提要.

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)

}

解决方案

When you created the project, in the User Interface pop-up, you chose SwiftUI.

Choose Storyboard instead.

这篇关于启动项目时没有viewcontroller.swift文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆