13

I would like to know how I can filter my list and create an alphabetical section index to the side of a List in SwiftUI, as is possible with the sectionIndexTitlesForTableView UITableViewDataSource delegate method in UIKit.

Here is an example of what I would like to do

How can I do this?

Here is the list I have so far: List built so far

12
  • Yes I Do, but how would I put the alphabetical list seen on the right graphically Commented Jan 7, 2020 at 23:16
  • Using a UITableView or a UICollectionView. Learning how to construct a view controller with a table view in it should be your starting point, not sorting an array alphanumerically. Commented Jan 7, 2020 at 23:19
  • So there is no way of doing it with the List view of swiftUI ?? Commented Jan 7, 2020 at 23:21
  • 3
    I have but what should I do now to make the alphabetical indexed list ? (See up for the list I made) Commented Jan 7, 2020 at 23:30
  • 4
    @bsod you should work on your politeness. OP's original question seems pretty well-formed an relevant to me. Didn't need you to be patronising and snarky. Be kinder please. Commented Mar 23, 2020 at 4:07

1 Answer 1

1

If you're looking for a similar delegate method in SwiftUI you won't find one. Not yet at least.

I would suggest building a separate VStack of the section indexes (array you built already as you normally would for the delegate). Then just wrap your section indexes and your List in a ZStack.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.