当前位置:网站首页>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)边栏推荐
- Dare not buy thinking
- 用键盘输入一条命令
- Detailed explanation of use scenarios and functions of polar coordinate sector diagram
- Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
- CISP-PTE之PHP伪协议总结
- Google Earth Engine(GEE)——Kernel核函数简单介绍以及灰度共生矩阵
- Mongodb getting started Tutorial Part 04 mongodb client
- Spring Festival Limited "forget trouble in the year of the ox" gift bag waiting for you to pick it up~
- 中间表是如何被消灭的?
- PHP strict mode
猜你喜欢

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

Batch update in the project

ES6 drill down - ES6 generator function

Single merchant v4.4 has the same original intention and strength!

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

Oneforall installation and use

Clear restore the scene 31 years ago, volcanic engine ultra clear repair beyond classic concert

服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】

Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL

Data access - entityframework integration
随机推荐
Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
Do sqlserver have any requirements for database performance when doing CDC
Global Data Center released DC brain system, enabling intelligent operation and management through science and technology
Cartoon: what is the eight queens problem?
Spring Festival Limited "forget trouble in the year of the ox" gift bag waiting for you to pick it up~
DeSci:去中心化科学是Web3.0的新趋势?
中间表是如何被消灭的?
【学术相关】多位博士毕业去了三四流高校,目前惨不忍睹……
普洛斯数据中心发布DC Brain系统,科技赋能智慧化运营管理
10 minutes to help you get ZABBIX monitoring platform alarm pushed to nail group
How was the middle table destroyed?
解决CMakeList find_package找不到Qt5,找不到ECM
JSON转MAP前后数据校验 -- 自定义UDF
StarkWare:欲构建ZK“宇宙”
The list set is summed up according to a certain attribute of the object, the maximum value, etc
How to set the WiFi password of the router on the computer
Detailed explanation of use scenarios and functions of polar coordinate sector diagram
Flet教程之 09 NavigationRail 基础入门(教程含源码)
APICloud云调试解决方案
[graduation season] as a sophomore majoring in planning, I have something to say