Swift UI List with section Index Titles

How to show section Indexes in Swift UI using List.


In case of UITableView we have section a datasource delegate to show the titles.


optional func sectionIndexTitles(for tableView: UITableView) -> [String]?


Does List , Section or ForEach support this functionality ?

Answered by Claude31 in 416939022

Do you want just to display this section number of make some use of it ?


Or would you want an index for the List, as for a TableView ?

Don't thinks Lists are that capable by now.


But could go and look here (I did not):

h ttps://www.reddit.com/r/SwiftUI/comments/dv7ddw/how_to_get_a_section_index_on_right_hand_side_of/


I would be interested to read if you found something useful there.

Hi,

Try this resource for all SwiftUI questions:


http://www.hackingwithswift.com/


This is a fantastic resource for Swift and SwiftUI questions, and I think you'll fiind the answer on there.


Dan

Accepted Answer

Do you want just to display this section number of make some use of it ?


Or would you want an index for the List, as for a TableView ?

Don't thinks Lists are that capable by now.


But could go and look here (I did not):

h ttps://www.reddit.com/r/SwiftUI/comments/dv7ddw/how_to_get_a_section_index_on_right_hand_side_of/


I would be interested to read if you found something useful there.

I am looking for List as solution. But yes I agree only thing as of now could be using UITableView as a specific view.

I think there is no other solution for the moment.

Don't forget to close the thread if you make it work with the proposed solution.

Swift UI List with section Index Titles
 
 
Q