Problem with dialogue

Hello i have build my own dialogue a normal hstack vstack its working not in scrollview and I have two Problems and no idea:

  • at fresh loading page or scroll at scroll view the dialogue is showing. by the second tap not :(
  • the ingoresafeplaces doesn't work.

do you have an solution?

Greeting Fabian

Answered by Claude31 in 785287022

@ Climber1987Muc

.onAppear works only onetime.

Yes, normal. The modifier name is a bit misleading. It works when the view loads (not when it appears on screen.

One trick is to create a dummy State var:

@State var dummy = false

Then in the body, enclose the part on which you had .onAppear inside:

if dummy || !dummy { // Will always be true
   // code on which .onAppear applied 
}

And in each place where you want to force redraw (like in a Button action or scroll onChange), call

dummy.toggle() // just to force a change in the state var

For the first problem:

I have found out the .onAppear works only onetime. there is a replacement?

Greeting Fabian

Accepted Answer

@ Climber1987Muc

.onAppear works only onetime.

Yes, normal. The modifier name is a bit misleading. It works when the view loads (not when it appears on screen.

One trick is to create a dummy State var:

@State var dummy = false

Then in the body, enclose the part on which you had .onAppear inside:

if dummy || !dummy { // Will always be true
   // code on which .onAppear applied 
}

And in each place where you want to force redraw (like in a Button action or scroll onChange), call

dummy.toggle() // just to force a change in the state var

@Claude31 thank you its works

Problem with dialogue
 
 
Q