当前位置:网站首页>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)边栏推荐
- 移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
- Data Lake (XIV): spark and iceberg integrated query operation
- RLock锁的使用
- Which keywords will conflict with the abstract keyword
- Verilog realizes the calculation of the maximum common divisor and the minimum common multiple
- 视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
- 公司自用的国产API管理神器
- Information collection of penetration test
- Parameter type setting error during batch update in project SQL
- EDI许可证和ICP经营性证有什么区别
猜你喜欢

视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革

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

【网易云信】超分辨率技术在实时音视频领域的研究与实践
![18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度](/img/e7/4f682814ae899917c8ee981c05edb8.jpg)
18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度

后台系统发送验证码功能

通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你

RLock锁的使用

Coding devsecops helps financial enterprises run out of digital acceleration

Defining strict standards, Intel Evo 3.0 is accelerating the upgrading of the PC industry

ES6 drill down - Async functions and symbol types
随机推荐
漫画:什么是服务熔断?
Cheer yourself up
OceanBase社区版之OBD方式部署方式本地安装
Record the pits encountered in the raspberry pie construction environment...
自己要有自己的坚持
Convert obj set to entity set
践行自主可控3.0,真正开创中国人自己的开源事业
企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
Use of RLOCK lock
list集合根据对象某属性求和,最大值等
定义严苛标准,英特尔Evo 3.0正在加速PC产业升级
vlunhub- BoredHackerBlog Social Network
Pits encountered in the use of boolean type in development
单商户 V4.4,初心未变,实力依旧!
Some cognitive thinking
You should have your own persistence
Arduino控制微小的六足3D打印机器人
The list set is summed up according to a certain attribute of the object, the maximum value, etc
Quelques réflexions cognitives
降本40%!Redis多租户集群的容器化实践