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
相关推荐
用户38034165882972 分钟前
八个私有 SPM 包撑起六款 App:分支当版本、钻石依赖,和一次谁都没报错的失效
ios·swift
YSL0701248 分钟前
一文通关-----栈和队列
开发语言·数据结构
维克兜率天18 分钟前
【维克】统计套利建模:从因子到信号的完整流程
android·开发语言·python·算法·kotlin
Pin_Qing23 分钟前
同一天,谷歌半价卖旗舰,阶跃翻倍收缓存
大数据·开发语言·人工智能·程序人生·缓存
2501_9307077829 分钟前
使用C#代码在 Word 文档中添加、插入或删除页面
开发语言·c#·word
没有梦想的咸鱼185-1037-166332 分钟前
从通量数据到SCI论文——AI-R语言生态系统碳水热通量及其机制分析与论文
开发语言·人工智能·数据分析·r语言
weixin_4617694038 分钟前
conda create 创建容器 Failed to resolve ‘repo.anaconda.com‘问题
开发语言·python·conda·repo·网络问题·无法创建
Want59540 分钟前
Python生日蛋糕
开发语言·python
老李IT笔记42 分钟前
远程取设备日志:iOS、tvOS 和 macOS 三端的同意方式不一样
macos·ios