当前位置:网站首页>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)
边栏推荐
- DeSci:去中心化科学是Web3.0的新趋势?
- 企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
- 有序链表集合求交集 方法 总结
- 【 brosser le titre 】 chemise culturelle de l'usine d'oies
- Domestic API management artifact used by the company
- The new version of effect editor is online! 3D rendering, labeling, and animation, this time an editor is enough
- Migrate /home partition
- 效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了
- Jarvis OJ 远程登录协议
- Cartoon: what is the eight queens problem?
猜你喜欢
随机推荐
Practice independent and controllable 3.0 and truly create the open source business of the Chinese people
[vulnerability warning] cve-2022-26134 conflict Remote Code Execution Vulnerability POC verification and repair process
Google Earth Engine(GEE)——Kernel核函数简单介绍以及灰度共生矩阵
Seaborn draws 11 histograms
How to use FRP intranet penetration +teamviewer to quickly connect to the intranet host at home when mobile office
2020-2022两周年创作纪念日
[deep learning] how does deep learning affect operations research?
面对新的挑战,成为更好的自己--进击的技术er
Win11 prompt: what if the software cannot be downloaded safely? Win11 cannot download software safely
Dare not buy thinking
Jarvis OJ Webshell分析
Record a 'very strange' troubleshooting process of cloud security group rules
Raspberry pie 4B installation pytorch1.11
Convert obj set to entity set
You should have your own persistence
Do sqlserver have any requirements for database performance when doing CDC
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
ES6 drill down - ES6 generator function
Oneforall installation and use
Flet教程之 11 Row组件在水平数组中显示其子项的控件 基础入门(教程含源码)