ios – Why The Navigation View would not present up utilizing SwiftUI?


I’ve the next recordsdata and I do not know why the navigation bar just isn’t exhibiting.

Within the first file I’m utilizing NavigationView earlier than ContentView().
File 1:

import SwiftUI

@major
struct TwitterCloneApp: App {
    var physique: some Scene {
        WindowGroup {
            NavigationView{
                ContentView()
            }
            
        }
    }
}

In second file I’m utilizing MainTabView(), however there isn’t any navigation bar area.

File 2

import SwiftUI


struct ContentView: View {
    
    @State personal var showMenu = false
    
    var physique: some View {
            ZStack(alignment: .topLeading){
                    MainTabView()

                
            }
           
        
    }
    
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Right here it’s the MainTabView.

File 3:

import SwiftUI

struct MainTabView: View {
    
    @State personal var selectedIndex: Int = 0
    
    var physique: some View {
            TabView(choice: $selectedIndex){
                FeedView()
                    .onTapGesture {
                        self.selectedIndex = 0
                    }
                    .tabItem{
                        Picture(systemName: "home")
                    }.tag(0)
                ExploreView()
                    .onTapGesture {
                        self.selectedIndex = 1
                    }
                    .tabItem{
                        Picture(systemName: "magnifyingglass")
                    }.tag(1)
                NotificationsView()
                    .onTapGesture {
                        self.selectedIndex = 2
                    }
                    .tabItem{
                        Picture(systemName: "bell")
                    }.tag(2)
                MessagesView()
                    .onTapGesture {
                        self.selectedIndex = 3
                    }
                    .tabItem{
                        Picture(systemName: "envelope")
                    }.tag(3)
            
            
        }
    }
    
}

struct MainTabView_Previews: PreviewProvider {
    static var previews: some View {
        MainTabView()
    }
}

There isn’t a area for the navigation bar.

enter image description here

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles