相信聪明的小伙伴已经开始对SwiftUI下手了吧。我这个后知后觉的现在才开始摸索,记录一下自己学习的过程。有方向才能发力。
先来学习一下最最最最常用的TableView吧。
首先SwiftUI的入口从AppDelegate更换到了SceneDelegate,其实也很简单
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Create the SwiftUI view that provides the window contents.
let contentView = ContentView()
// Use a UIHostingController as window root view controller.
if let windowScene = scene as? UIWindowScene {