UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Tabview Question...

Forums > SwiftUI

First of all, thank you Paul you have already helped me save countless hours during my re-learning to code with SwiftUI! For almost every feature I was trying to build in a SwiftUI app I have been building I have found some useful article or video to help me along. As a total newbie in iOS / Swift dev this has been an enormous help often times easier to understand than other tutorials and even some Udemy courses I had purchased. As a show of appreciation I have subscribed to the monthly channel and look forward to learning many other fun things from Paul.

I do have a question now that I hope someone can shed some light on. I have put a tabview in my app and I was wondering if there was some way to either hide or disable the tabs when in a particular view. In checking around on the web this seems to be a known problem but I was wondering if anyone could point me at a easy workaround since I am not that knowledgable about how the various frameworks can be hacked to work around SwiftUI limitations.

My app has three tabs and one of those is a Navigation view that can lead in a series of steps Category List -> Routine List -> Routine Detail -> Play Animation View. In this last view I would like to hide the tabbar so that the user cannot leave the animation playing and switch to one of the three tabview items. Otherwise the animation (and sound) keep playing but there is no way to get back to it and stop it without just killing the app. I also tried putting an .ondisappear event on this view thinking that I could get it to quit itself if the user did cick on another tab but for some reason it doesn't seem to get triggered. Ideally I would just want to hide the tabbar for that view and force the user to either play the entire routine or quit the animation and return to the Routine Detail view before visiting any of the tabview items. Any help would be greatly appreciated!

UPDATE: I have figured out this issue is somehow related to the ZStack that is included in the animation view. I have a view that includes a series of VStacks one of which includes a set of nested ZStacks that support the animation. If I take out the VStack that includes these ZStack's the .ondisappear event is triggered when the user switches views via the tabview so the ZStack's must somehow be obscurring the .ondisppear event? Does anyone have an idea as to what might be going on here? Structure looks like this. So the ZStacks are in their own VStack which I assumed could not overlap the next VStack but perhaps I am wrong?

VStack {

VStack {

  some view items

          }

  VStack {

      ZStack {
          some animation view
        ZStack {
            some animation view
          ZStack {
                some animation view       
                       }
                    }
                  }
                }
     VStack {
              Text view that contains the .ondisappear      
                   }
  }

3      

Obviously there is no easy way to hide a tabbar on particular views so I just decided to us a modal to cover up the tabbar for the particular view in question. Surprised no one had any suggestions for me. Perhaps the question was too simpleminded for this crowd.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.