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
相关推荐
怪兽20141 小时前
fastjson在kotlin不使用kotlin-reflect库怎么使用?
android·开发语言·kotlin
ClearLiang1 小时前
Kotlin-协程的挂起与恢复
开发语言·kotlin
彭同学学习日志1 小时前
Kotlin Fragment 按钮跳转报错解决:Unresolved reference ‘floatingActionButton‘
android·开发语言·kotlin
海域云赵从友1 小时前
破解跨境数据传输瓶颈:中国德国高速跨境组网专线与本地化 IP 的协同策略
开发语言·php
咚咚王者1 小时前
人工智能之编程进阶 Python高级:第九章 爬虫类模块
开发语言·python
2501_915918411 小时前
移动端 HTTPS 抓包实战,多工具组合分析与高效排查指南
数据库·网络协议·ios·小程序·https·uni-app·iphone
深蓝海拓2 小时前
使matplot显示支持中文和负号
开发语言·python
Digitally2 小时前
解决“Move to iOS 卡在准备中”的 9 种有效方法
macos·ios·cocoa
syt_biancheng2 小时前
Day3算法训练(简写单词,dd爱框框,3-除2!)
开发语言·c++·算法·贪心算法
864记忆3 小时前
Qt Network 模块中的函数详解
开发语言·网络·qt