当前位置:网站首页>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)
边栏推荐
- Detailed explanation of use scenarios and functions of polar coordinate sector diagram
- HiEngine:可媲美本地的云原生内存数据库引擎
- 不敢买的思考
- Accès aux données - intégration du cadre d'entité
- Data access - entityframework integration
- 详解SQL中Groupings Sets 语句的功能和底层实现逻辑
- Mistakes made when writing unit tests
- Research and development efficiency measurement index composition and efficiency measurement methodology
- Sentinel flow guard
- Quelques réflexions cognitives
猜你喜欢
【刷题篇】有效的数独
Win11 prompt: what if the software cannot be downloaded safely? Win11 cannot download software safely
【刷题篇】鹅厂文化衫问题
CISP-PTE之PHP伪协议总结
Win11如何给应用换图标?Win11给应用换图标的方法
为季前卡牌游戏 MotoGP Ignition Champions 做好准备!
Flet tutorial 12 stack overlapping to build a basic introduction to graphic and text mixing (tutorial includes source code)
scratch五彩糖葫芦 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
Seaborn绘制11个柱状图
Global Data Center released DC brain system, enabling intelligent operation and management through science and technology
随机推荐
數據訪問 - EntityFramework集成
PHP strict mode
[echart] resize lodash 实现窗口缩放时图表自适应
[es6] 模板字符串内添加if判断或添加三元运算符判断
10 minutes to help you get ZABBIX monitoring platform alarm pushed to nail group
Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
How to uninstall MySQL cleanly
Solve the Hanoi Tower problem [modified version]
Query the latest record in SQL
The list set is summed up according to a certain attribute of the object, the maximum value, etc
Reduce the cost by 40%! Container practice of redis multi tenant cluster
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
详解SQL中Groupings Sets 语句的功能和底层实现逻辑
怎样在电脑上设置路由器的WiFi密码
普洛斯数据中心发布DC Brain系统,科技赋能智慧化运营管理
Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)
Enterprise backup software Veritas NetBackup (NBU) 8.1.1 installation and deployment of server
The new version of effect editor is online! 3D rendering, labeling, and animation, this time an editor is enough
不敢买的思考
Seaborn绘制11个柱状图