Saturday, November 21, 2026
HomeiOS Developmentios - Replace ProgressView worth from one other ViewController with out utilizing...

ios – Replace ProgressView worth from one other ViewController with out utilizing @Binding?

[ad_1]

At present I declare my ProgressView in my foremost view controller which will get it is worth from a @State variable. On a button press i modify the worth of the variable which then updates the worth of my progress bar.

I need to make modifications to this ProgressView, however utilizing a button on a separate view controller. I’ve tried to make use of Binding, however because of the method I’m utilizing WatchTabView, this forces me to declare a @Binding variable inside my App struct, which is not potential.

Undecided if I am overthinking this, however how am i able to replace my progress bar from one other view?

Fundamental View

struct ViewController: View {

@State var progressBarValue = 5.0 

 var physique: some View {
        ScrollView{

  ProgressView("Effort", worth: progressBarValue, complete: 20)
        VStack {

 Button{ 

progressBarValue += 5.0

}label:{
Textual content("Click on")
}

Different View

struct OtherViewController: View{

...

Button{

//I need to improve progressBarValue by clicking right here

}label:{
Textual content("Click on")
}

...
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments