当前位置:网站首页>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)边栏推荐
猜你喜欢

Jarvis OJ Webshell分析

ES6深入—async 函数 与 Symbol 类型

Single merchant v4.4 has the same original intention and strength!
![[brush title] goose factory shirt problem](/img/c8/44496c767a778101cf3982bd911933.png)
[brush title] goose factory shirt problem

效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了

Data access - entityframework integration

二叉树相关OJ题

File operation --i/o

Batch update in the project

Spring Festival Limited "forget trouble in the year of the ox" gift bag waiting for you to pick it up~
随机推荐
为季前卡牌游戏 MotoGP Ignition Champions 做好准备!
数据访问 - EntityFramework集成
国泰君安网上开户安全吗
Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
给自己打打气
【刷题篇】鹅厂文化衫问题
如何将mysql卸载干净
sqlserver 做cdc 要对数据库性能有什么要求么
【刷題篇】鹅廠文化衫問題
2020-2022两周年创作纪念日
普洛斯数据中心发布DC Brain系统,科技赋能智慧化运营管理
Can you help me see what the problem is? [ERROR] Could not execute SQL stateme
降本40%!Redis多租户集群的容器化实践
Sentinel-流量防卫兵
效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了
Single merchant v4.4 has the same original intention and strength!
10分钟帮你搞定Zabbix监控平台告警推送到钉钉群
Flet教程之 09 NavigationRail 基础入门(教程含源码)
漫画:什么是蓝绿部署?
Migrate /home partition