SwiftUi:tabviews和导航视图当TabViews不是主页时的问题
下午好,
我在应用程序上有一个问题。第一次启动该应用程序时,用户将显示登录页面并注册页面(没有TabView),一旦登录,它们就会将其定向到带有不同部分的TabView(主页,聊天等)。 )。
我遇到的主要问题是,从登录视图更改为tabview时,设置的导航列表仅是家庭视图的导航词,而更改为其他选项卡时,标题不会更改。我该如何解决这个问题,其他应用程序如何处理?
谢谢。
文件loginview
import SwiftUI
struct LoginView: View {
var body: some View{
NavigationView{
NavigationLink(destination: TabView, label: Text("Login")
}
}
}
文件tabview
import Swift UI
struct TabView: View {
var body: some View{
TabView {
HomeView()
.tabItem{
//Not relevant code
}
ChatView()
.tabItem{
//Not relevant code
}
}
}
}
文件homeview
import SwiftUI
struct HomeView: View {
var body: some View {
ZStack{
//Not relevant code
}
.navigationBarTitle("Home")
}
}
文件chatsview
import SwiftUI
struct ChatsView: View {
var body: some View {
ZStack{
//Not relevant code
}
.navigationBarTitle("Chats")
}
}
Good afternoon,
I have a problem on my app with the NavigationViews. When launching the app for the very first time, users are displayed a LogIn and Sign Up page (which does not have a TabView) and once they Log-In they are directed to a TabView with different sections (Home, Chats, etc...).
The main problem that I have is that when changing from the Login view to the TabView,the NavigationTitle that is set is only that of HomeView and when changing to a different tab, the title does not change. How could I solve this problem, how do other apps deal with this?
Thank you.
File LoginView
import SwiftUI
struct LoginView: View {
var body: some View{
NavigationView{
NavigationLink(destination: TabView, label: Text("Login")
}
}
}
File TabView
import Swift UI
struct TabView: View {
var body: some View{
TabView {
HomeView()
.tabItem{
//Not relevant code
}
ChatView()
.tabItem{
//Not relevant code
}
}
}
}
File HomeView
import SwiftUI
struct HomeView: View {
var body: some View {
ZStack{
//Not relevant code
}
.navigationBarTitle("Home")
}
}
File ChatsView
import SwiftUI
struct ChatsView: View {
var body: some View {
ZStack{
//Not relevant code
}
.navigationBarTitle("Chats")
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
}
}