Post

Replies

Boosts

Views

Activity

SwiftUI: onPreferenceChange not called if view contains if statement
Hi, I'm trying to build iOS app, but I found out that .onPreferenceChange has strange behaviour if the view contains an if statement below view which sets .preference. Here is an repository with minimal reproduction: https://github.com/Mordred/swiftui-preference-key-bug There should be displayed title text on the top and bottom of the screen. But the bottom is empty. If you delete if statement if true { at https://github.com/Mordred/swiftui-preference-key-bug/blob/main/PreferenceKeyBug/PreferenceKeyBug.swift then it works fine.
1
4
778
Jul ’23