Post

Replies

Boosts

Views

Activity

iPad app now crashing on Mac. layoutSubtreeIfNeeded ?
My ipAd app is now crashing when being run on a Mac (with designed for iPad emulator). It. has been working a month ago, today was first time I tried in awhile. I get a warning "It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out. If you are implementing the view's -layout method, you can call -[super layout] instead. Break on void _NSDetectedLayoutRecursion(void) to debug. This will be logged only once. This may break in the future." shortly after that the App Crashes. Thread 1: EXC_BAD_ACCESS (code=1, address=0x14a0839653d0) The crash happens when my main view (in a Tab view) goes to a DetailView. I stripped out all functionality in my code and it still happens mainView NavigationLink{ ImageDetailView2 () } label: { img } struct ImageDetailView2: View { var body: some View { Text("Hello, World!") } } Any help would be appreciated
3
0
179
3w
swiftui. need .isVisible() {}. or similar
Im using a lazyvgrid with a customImage View that supports lazy loading of a high res image (otherwise thumb is used) What I'm looking for is some way to initiate my loadFullImage() functionality when the CustomImage view is visible ( onAppear() is not what I need. its called when view is loaded in grid, not when visible ) I've tried variation of this, but they do not work reliably CustomImage(key: key) .background( GeometryReader { proxy in Color.clear .preference(key: ViewVisibleKey.self, value: true) } ) .onPreferenceChange(ViewVisibleKey.self) { isVisible in DispatchQueue.main.async { loadImage(key) } } } Anyone have any suggestions ? either why the code above doesn't work reliably (its like 10%) , or some other way to accomplish this. Thanks
0
0
228
Jul ’24
how to get notified when window size changes w app running on Mac
I have a swiftui iPhone app running on the "iOS Apps on Mac" simulator. What I'm trying to do is get a notification when the window size changes, but nothing seems to work. I have tried .onReceive(NotificationCenter.default.publisher(for: UIContentSizeCategory.didChangeNotification)) { _ in updateStuff() } I also tried .onAppear() { updateStuff() } but neither seems to get called any suggestions ?
0
0
321
May ’24
Lazyvgrid visual promblems after orientation change
I'm having issues with a Lazyvgrid displaying images after the screen orientation changes ( either from horizontal to portrait, or the reverse ) What happens is the images are not sized correctly. If 2 column , I see 1/3 of column 1 and the image in column 2 takes 2/3 of the screen width. Similar issues with 3 or 6 column layout. The Lazyvgrid is inside a ScrollView and thats inside a Tabview. I'v tried to trick an update by changing the column layout, the content mode (fit/fill) of the images, etc. but so far nothing has worked. Any suggestions ?, anyway to invalidate a lazyvgrid and have swiftui rebuild it ? Thanks.
1
0
388
May ’24