Is there a way of running code after the view appeared? If I use ".onAppear", my code gets executed and when it is finished, the view appears. But I want that the view appears first and then my code gets executed automatically. Thanks
Asked
Active
Viewed 355 times
0
-
1Did you try a .task _{} in place or after .onAppear {} ? – Ptit Xav Jul 26 '22 at 08:32
-
Never know you could use task like that but I will try and tell the results – Pjaks Jul 26 '22 at 08:38
-
You can add Dispatchque with some seconds delay. – Kudos Jul 26 '22 at 08:41
-
SwiftUI does not report "appear visible on screen" state, so either use UIKit (say via representable) or, better, do not refer on that at all. BTW, SwiftUI.onAppear means "appear in view hierarchy" (equivalent to `didMoveToSuperview`). – Asperi Jul 26 '22 at 09:04