Hi, so I have been learning SwiftUI for a while. Recently, I have been facing this and have not been able to find a solution for it. I have noticed that when GeometryReader is enclosed inside a NavigationView then width and height of size are both 0.
This issue can be fixed if NavigationView is enclosed inside GeoemetyReader but it won't fix my issue as I plan to load another view which has GeometryReader inside it and it must be loaded inside NavigationView
Thanks
Code Block var body: some View { NavigationView { GeometryReader { geometryProxy in VStack { ZStack { /* Here size.width and size.height are both 0 */ draw_lines_of_quadrant(screen_width: geometryProxy.size.width, screen_height: geometryProxy.size.height) } } } } }
This issue can be fixed if NavigationView is enclosed inside GeoemetyReader but it won't fix my issue as I plan to load another view which has GeometryReader inside it and it must be loaded inside NavigationView
Thanks
Always be ready for being evaluated multiple times.So is there any elegant way to find out if it's being evaluated the second time?
You may need to make your method 0-size-tolerant.It crashes the view because of those 0s.
(Your code looks like an old C-code and very hard to read. I strongly recommend you to follow the modern coding rules. You are writing code in Swift, not C.)
Code Block var body: some View { NavigationView { GeometryReader { geometryProxy in VStack { ZStack { if geometryProxy.size != .zero { draw_lines_of_quadrant(screen_width: geometryProxy.size.width, screen_height: geometryProxy.size.height) } } } } } }