当前位置:网站首页>Apple 已弃用 NavigationView,使用 NavigationStack 和 NavigationSplitView 实现 SwiftUI 导航
Apple 已弃用 NavigationView,使用 NavigationStack 和 NavigationSplitView 实现 SwiftUI 导航
2022-07-05 15:47:00 【知识大胖】
Apple 已弃用 NavigationView,它以前被用作封装视图堆栈,这些视图本质上是在呈现时推送并在关闭时弹出的视图。这是 iOS 导航从一开始就使用的熟悉方式,没有物理后退按钮,但顶部有一个导航栏,有一个后退按钮,描述了“后退”的位置。
有两种实现导航的新方法,但它们最终在 iPhone 上看起来非常相似,原因我将在后面讨论。
让我们开始吧!
NavigationStack
这个应用程序非常简单地从几个Hashable和Identifiable结构开始。
Screen存储导航状态的枚举必须是Hashable,因为新的初始化程序需要NavigationLink它,我稍后将使用它。为了成为Hashable相关的值也需要是Hashable。如果它们只是 String和 an ,这仍然是正确的Int,但我想利用ForEachwhich 要求类型也是Identifiable。作为原始值类型String并且Int是可互换的,并且它们没有定义它们的唯一属性。
我已将数据添加ContentView为两个数组。
我可以(并且可能应该)使用 anObservableObject来存储数据,但我宁愿编写更多代码来专门演示导航。
import Foundation
struct Word: Hashable, Identifiable {
let id = UUID()
let name: String
}
struct Number: Hashable, Identifiable {
let id = UUID()
let value: Int
}
enum Screen: Hashable {
case word(Word)
case number(Number)边栏推荐
猜你喜欢

Coding devsecops helps financial enterprises run out of digital acceleration

vulnhub-FirstBlood

超分辨率技术在实时音视频领域的研究与实践

Li Kou today's question -729 My schedule I

Data communication foundation ACL access control list

Why should we learn mathematical modeling?

单商户 V4.4,初心未变,实力依旧!

Replknet: it's not that large convolution is bad, but that convolution is not large enough. 31x31 convolution. Let's have a look at | CVPR 2022

新春限定丨“牛年忘烦”礼包等你来领~

List de duplication and count the number
随机推荐
The list set is summed up according to a certain attribute of the object, the maximum value, etc
20.[STM32]利用超声波模块和舵机实现智能垃圾桶功能
Use of RLOCK lock
vant tabbar遮挡内容的解决方式
Apiccloud cloud debugging solution
Research and practice of super-resolution technology in the field of real-time audio and video
阿掌的怀念
APICloud云调试解决方案
Clock switching with multiple relationship
Single merchant v4.4 has the same original intention and strength!
Find the root of the following equation by chord cutting method, f (x) =x^3-5x^2+16x-80=0
数据湖(十四):Spark与Iceberg整合查询操作
Obj resolves to a set
ES6 drill down - ES6 generator function
自己要有自己的坚持
Intelligent metal detector based on openharmony
对象和类的关系
[graduation season] as a sophomore majoring in planning, I have something to say
漫画:什么是蓝绿部署?
Exception com alibaba. fastjson. JSONException: not match : - =