Hi all, I've been working on an app for months and have recently came across the below problem.
I have a listView with a NavigationView in SwiftUI. When I go into the list, there is NO NavigationBar title or Buttons above it. When I start to scroll, it appears, and then disappears when I go to the top of the list. It has suddenly appeared without any rhyme or reason. I have seen this question asked before and a solution. I have tried it and it still is a problem.
Here's the code:
import Foundation
struct MainMenu: View {
@State private var mainOptions: Int? = 0
@State private var tag: Int = 0
var fSize = Int(20)
var body: some View {
NavigationView() {
List {
Section(header: Text("MAIN INFORMATION"))
{
NavigationLink(destination: Introduction(), tag:1, selection: $mainOptions) {
Image(systemName: "doc")
Text("Introduction")
.bold()
}
NavigationLink(destination: BeSafe(), tag:2, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Be Safe")
.bold()
}
NavigationLink(destination: MythsAndFacts(), tag:3, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Myths and Facts")
.bold()
}
NavigationLink(destination: CycleofViolence(), tag:4, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Cycle of Violence")
.bold()
}
NavigationLink(destination: Definition(), tag:5, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Definitions")
.bold()
}
NavigationLink(destination: PersonalSafetyPlan(), tag:6, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Personal Safety Plan")
.bold()
}
NavigationLink(destination: PPOs(), tag:7, selection: $mainOptions)
{
Image(systemName: "doc")
Text("PPOs")
.bold()
}
NavigationLink(destination: QuestionsOnLeaving(), tag:8, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Questions on Leaving")
.bold()
}
NavigationLink(destination: AbuseMenu(), tag:9, selection: $mainOptions)
{
Image(systemName: "doc")
Text("Information on Abuse")
.bold()
}
}
Section(header: Text("GET MORE INFORMATION"))
{
NavigationLink(destination: PhoneNumbers())
{
Image(systemName: "phone")
Text("Phone Numbers")
.bold()
}
NavigationLink(destination: Search())
{
Image(systemName: "safari")
Text("Search")
.bold()
}
}
Section(header: Text("TAKE NOTES"))
{
NavigationLink(destination: CPNoteLite())
{
Image(systemName: "note.text")
Text("CPNote Lite")
.bold()
}
NavigationLink(destination: CPNoteHelp())
{
Image(systemName: "questionmark")
Text("Help with CPNote Lite")
.bold()
}
}
Section(header: Text("FOR YOUR PROTECTION"))
{
NavigationLink(destination: HideInfo())
{
Image(systemName: "book.closed")
Text("Hide This App.")
.bold()
}
}
}
}.navigationTitle("Domestic Violence")
.navigationBarTitleDisplayMode(.inline)
.toolbar
{
ToolbarItem(placement: .bottomBar)
{
HStack {
Image(systemName: "c.circle")
.resizable()
.frame(width: 20, height: 20)
Text("2021 Connecting People Software")
.font(.custom("", size: 18))
}
}
}
.navigationBarItems(leading: NavigationLink(destination: About(),
label: {
Image(systemName: "info.circle")
.font(.custom("", size: 18))
}), trailing: NavigationLink(destination: Support(),
label: {
Image(systemName: "person.circle")
.font(.custom("", size: 18))
}))
}
}
struct MainMenu_Previews: PreviewProvider {
static var previews: some View {
MainMenu()
.previewInterfaceOrientation(.portrait)
}
}
Thank you, Dan Uff