NEW: Learn to build the incredible iOS 15 Weather app today! >>

Navigation Views popping too early

Forums > SwiftUI

I'm creating an app and am having trouble with the navigation views. From the main menu (level 1) I'm good opening browse (level 2) and then detail (level 3).

In two spots now I'm opening a browse view and it appears to work fine but if I delete a row in the list it goes back (closes the view) and I can't figure out why. In both cases I'm coming from the main menu (level 1) and open a view (level 2) and then the browse is opened.

Example 1: coming from a view (level 2) that holds a List of manually created NavigationalLinks and Text. This opens into a browse that I also use with no difficulty from the main menu. There's a list of CoreData entities, has no problem opening, and I can open and edit the detail view. BUT when I delete a row it pops the view and I return to to level two.

In a list: NavigationLink(destination: MyBrowse(parameters:values) { Text("Label") }

Example 2: coming from a view (level 2) containing, at this time, just buttons. I started out having the NavigationLink at the top and ".hidden" but now moved it to the bottom within ".background()". Either way It's turned on with an "isActive" boolean. This opens if there's only one or two items in the list but flickers (pops) if there's three or more items OR if I delete a row like example 1.

Was in the list and set to hidden: NavigationLink(destination: MyBrowse(parameters:values), isActive: $showBrowseView)), isActive: $showTemplateBrowseView, label: { EmptyView() }) .hidden()

But now moved it to a background modifier with the same results .background(NavigationLink("", destination: MyBrowse(parameters:values), isActive: $showBrowseView))

In either case it's shown when I set showBrowseView to true.


Both times the same browse view is being open although in the second case there's more filtering down on the CoreData entity.

I had trouble googling my problem and figured I'd ask in case anyone else saw something similar.

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED Learn the most up-to-date techniques and strategies for testing new and legacy Swift code in this free practical course for iOS devs who want to become complete Senior iOS Developers.

Learn more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.