SwiftUI篇-1 项目结构

摘要:

介绍Xcode新建的SwiftUI模版项目结构、跟普通Storyboard模版项目的差异、SwiftUI项目的app启动流程、UIScene概念介绍、AppDelegate.swift和Info.plist的差异

1.项目模版

Interface: SwiftUI

Life Cycle: UIKit App Delegate

Language: Swift

Life Cycle选择UIKit App Delegate是为了项目模版有app生命周期,方便跟普通app生命周期做比较


 2.差异性

1)AppDelegate.swift

import UIKit

@main

class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // Override point for customization after application launch.

        return true

    }

    // MARK: UISceneSession Lifecycle

    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {

        // Called when a new scene session is being created.

        // Use this method to select a configuration to create the new scene with.

        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)

    }

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {

        // Called when the user discards a scene session.

        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.

        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.

    }

}

app原本的生命周期不见了?增加了UISceneSession的生命周期!

swiftUI增加了Scene场景的概念,app可以切换scene场景

scene场景:pc电脑或某些iPad可以在一个app软件里面打开多个window窗口,一个window窗口就是对应一个scene场景,如火狐浏览器可以同时打开多个窗口,一个窗口显示百度首页,一个窗口显示火狐首页,如下:

还有 72% 的精彩内容
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。
支付 ¥1.00 继续阅读

相关阅读更多精彩内容

  • iOS13内容全介绍 ​ WWDC2019发布了iOS13,将随新iPhone发售正式发布。对于移动开发而言,最关...
    sycasl阅读 11,076评论 0 0
  • Astronomygonova - A wrapper for libnova -- Celestial Mech...
    JumboWu阅读 12,991评论 0 41
  • 为了实现iPadOS支持多窗口,Xcode11后创建新工程默认会通过 UIScene 创建并管理多个 UIWind...
    codeTao阅读 11,575评论 1 15
  • iOS13 项目中的SceneDelegate类有什么作用?自从Xcode11发布以来,当你使用新XCode创建一...
    乐Coding阅读 30,996评论 14 61
  • 推荐指数: 6.0 书籍主旨关键词:特权、焦点、注意力、语言联想、情景联想 观点: 1.统计学现在叫数据分析,社会...
    Jenaral阅读 11,035评论 0 5

友情链接更多精彩内容