swift-碰到的问题

如何让工程不使用storyboard和scene

删除info.plist里面的Application Scene mainifest

删除SceneDelegate.swift

删除AppDelegate.swift里面的这两个方法

objectivec 复制代码
 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {

然后在appDelegate,swift里面添加

objectivec 复制代码
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?//添加window

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow(frame: UIScreen.main.bounds)  
        // 设置根视图控制器
        var VC = UIViewController()
        VC.view.backgroundColor = UIColor.blue
          let rootViewController = VC  // 替换为你的视图控制器
          window?.rootViewController = rootViewController
        window?.makeKeyAndVisible()//让window可以被看见
        
        return true
    }

}

当点击一个button时显示出下一个ViewController

点击注册后跳转到

左上角自动会有返回的按钮

可以直接在IB界面在添加了VavigationViewController的ViewController里面的button,直接拉线到另一个VC就可以实现这个功能

首先需要将loginViewController包含进一个navigationViewController里面

创建登录button的行为 为

swift 复制代码
self.navigationController?.pushViewController(registerVC, animated: true)//registerVC为需要显示出来的VC
相关推荐
AC赳赳老秦9 分钟前
用 OpenClaw 整理团队技术分享:自动提取 PPT 内容、生成文字稿、同步到知识库
开发语言·python·自动化·powerpoint·wpf·deepseek·openclaw
whatever who cares11 分钟前
android中fragment demo举例
android·java·开发语言
Vallelonga13 分钟前
Rust 生命周期标注积累
开发语言·rust
caimouse17 分钟前
mshtml/nsio.c 实现报告
c语言·开发语言
龙侠九重天26 分钟前
C# 构建 AI Agent 系统 — 我的实践笔记
开发语言·人工智能·语言模型·自然语言处理·大模型·agent·智能体
SilentSamsara27 分钟前
Pandas 工程化:多层索引、分组聚合与窗口函数的进阶用法
开发语言·python·青少年编程·pandas
何以解忧,唯有..28 分钟前
Python 字符串完全指南:从基础到高级操作
开发语言·python
kiss strong30 分钟前
自制请求工具
开发语言·python·lua
scan72431 分钟前
短期记忆记忆存储在内存里,一个会话里的多轮对话
开发语言·c#
程序员皮皮林1 小时前
Dubbo 的 SPI 和 JDK 的 SPI 有什么区别?
java·开发语言·dubbo