apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.
MIT License
1.36k stars 160 forks source link

NavigationLink not working on section headers and footers #185

Closed yjosephides closed 3 years ago

yjosephides commented 4 years ago

Describe the bug When I wrap my section header view in a navigation link, no navigation is executed when the conditions are met

To Reproduce ASCollectionViewSection(...) .sectionHeader { NavigationLink(...) { HeaderView() } }

Xcode Version:

Simulator, Device, Both?

MrCarter31 commented 4 years ago

Im having this problem too

seboslaw commented 4 years ago

+1

apptekstudios commented 3 years ago

Unfortunately, SwiftUI isn't recognising navigation links when they are wrapped within UIKit elements. Without apple exposing some of their private APIs I can't get around this within the library itself.

There are some useful ideas on this blog (https://fivestars.blog/swiftui/programmatic-navigation.html) - he suggests how to use a single navigation link (which would be outside of the ASCollectionView) to handle all the necessary navigations. With this you should be able to achieve what you want 😄