Post

Replies

Boosts

Views

Activity

Debugging to find out why View is bring re-drawn
Hey all, I have a complex View that sometimes it's getting re-created for some events that I do not understand. I put the _PrintChanges() in the View body, and here's what I got: EditPageComponentControlHostView: @self, @identity, _pageController, _componentController, _hasContent changed. struct EditPageComponentControlHostView: View { @Environment(EditPageController.self) var pageController @State private var componentController = EditPageComponentController() @State private var hasContent = false It seems like the View is being reset since the @State hasContent has been reset. It seems like if the View's @identity has changed, SwiftUI will re-create the view hence the variable _hasChanged has been reset. So I tried: conform EditPageComponentControlHostView to Equatable, and @identity is still changing. Set id on EditPageComponentControlHostView like this: EditPageComponentControlHostView() .id("Test") and it still changing the identity. What did I miss? Thanks!
1
0
308
Feb ’24
How to prevent scene restoration in a catalyst app
Hello all, I'm porting my existing app to catalyst with optimized for mac option. However, I noticed the app will sometimes restore previous open windows if I previously kill it in Xcode. However, these restored windows are also just showing the app entry content instead of restoring the previous scene content. Question, is there anyway to disable this restore scene behavior? Thanks!
1
0
580
Dec ’23