当前位置:网站首页>Apple has abandoned navigationview and used navigationstack and navigationsplitview to implement swiftui navigation
Apple has abandoned navigationview and used navigationstack and navigationsplitview to implement swiftui navigation
2022-07-05 16:40:00 【Knowledge fatness】
Apple Have been abandoned NavigationView, It was previously used to encapsulate the view stack , These views are essentially views pushed during rendering and popped up when closing . This is a iOS Navigation is a familiar way to use from the beginning , There is no physical back button , But there is a navigation bar at the top , There is a back button , It describes “ back off ” The location of .
There are two new ways to implement navigation , But they end up iPhone It looks very similar , The reason I will discuss later .
Let's get started !
NavigationStack
This application is very simple from several Hashable and Identifiable Structure began to .
Screen The enumeration that stores the navigation state must be Hashable, Because the new initialization program needs NavigationLink it , I'll use it later . In order to be Hashable The relevant value also needs to be Hashable. If they just String and an , This is still true Int, But I want to use ForEachwhich The required type is also Identifiable. As the original value type String also Int It's interchangeable , And they don't define their unique properties .
I have added data ContentView Is two arrays .
I can ( And probably should ) Use anObservableObject To store data , But I'd rather write more code to specifically demonstrate navigation .
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)边栏推荐
- ES6深入—async 函数 与 Symbol 类型
- Cartoon: what is blue-green deployment?
- [es6] 模板字符串内添加if判断或添加三元运算符判断
- Batch update in the project
- 一些认知的思考
- Starkware: to build ZK "universe"
- 10 minutes to help you get ZABBIX monitoring platform alarm pushed to nail group
- 养不起真猫,就用代码吸猫 -Unity 粒子实现画猫咪
- Flet tutorial 12 stack overlapping to build a basic introduction to graphic and text mixing (tutorial includes source code)
- 新春限定丨“牛年忘烦”礼包等你来领~
猜你喜欢

CISP-PTE之PHP伪协议总结

Binary tree related OJ problems

ES6 deep - ES6 class class

Win11 prompt: what if the software cannot be downloaded safely? Win11 cannot download software safely

2020-2022 two-year anniversary of creation

數據訪問 - EntityFramework集成

Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)

清晰还原31年前现场,火山引擎超清修复Beyond经典演唱会

Flet tutorial 12 stack overlapping to build a basic introduction to graphic and text mixing (tutorial includes source code)

Pspnet | semantic segmentation and scene analysis
随机推荐
数据湖(十四):Spark与Iceberg整合查询操作
Transaction rollback exception
Starkware: to build ZK "universe"
[js] skill simplification if empty judgment
Cartoon: what is MapReduce?
The new version of effect editor is online! 3D rendering, labeling, and animation, this time an editor is enough
【刷题篇】鹅厂文化衫问题
阿掌的怀念
Sentinel flow guard
Win11如何给应用换图标?Win11给应用换图标的方法
[es6] 模板字符串内添加if判断或添加三元运算符判断
How can programmers improve their situation?
Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
文件操作--I/O
Bs-xx-042 implementation of personnel management system based on SSM
Benji Banas membership pass holders' second quarter reward activities update list
[vulnerability warning] cve-2022-26134 conflict Remote Code Execution Vulnerability POC verification and repair process
DeSci:去中心化科学是Web3.0的新趋势?
Summary of methods for finding intersection of ordered linked list sets
The database of the server is not connected to 200310060 "unknown error" [the service is up, the firewall is off, the port is on, and the netlent port is not connected]