0

Please reopen, I've found a solution. None of the links provided target this question.

I've tried removing Navigation bar of the List, pushing VStack to top, I don't know what else could it be...

How do I remove all that extra space?

enter image description here

    struct Ocean: Identifiable, Hashable {
        let name: String
        let id = UUID()
    }
    var oceans = [
        Ocean(name: "A"),
        Ocean(name: "B"),
        Ocean(name: "C"),
        Ocean(name: "D"),
        Ocean(name: "E")
    ]
    
    @State var multiSelection = Set<UUID>()
    
    var body: some View {
        NavigationView {
            VStack {
                Divider()
                
                Text("some text")
                
                List(oceans, selection: $multiSelection) {
                    Text($0.name)
                }
                
                Text("some text2")
                
                Spacer()
            }
        }
    }
}

EDIT: Please reopen the question, none of the links provided answer it and I've found the solution, need to post it.

Arturo
  • 3,254
  • 2
  • 22
  • 61
  • Does this answer your question: [SwiftUI - Resizable List height that dependent on an element count](https://stackoverflow.com/questions/58060530/swiftui-resizable-list-height-that-dependent-on-an-element-count)? Essentially, List ALWAYS takes up all the room it can. – Yrb Jul 31 '21 at 18:45
  • Hi, none of the questions are good as of now, I tried both links and it's still bugged. The way around is using LazyStacks but that way I loose the functions of Lists such as delete by swiping and things like that – Arturo Jul 31 '21 at 23:32
  • What you could do is add the .listStyle(PlainListStyle()) modifier to the closing bracket of your list. – nickreps Aug 01 '21 at 03:41
  • I am not sure you did read the links. This is the expected behavior of List, and there is no good way to change it. The bottom line from the links is that you need to do something different. – Yrb Aug 01 '21 at 16:36
  • @Yrb hi, I did, honestly the question shouldn't have been closed, and rather provide an alternative. The alternative I found was to use LazyStacks, it's less convenient but works :) – Arturo Aug 01 '21 at 17:39
  • I didn't close the question, but I agree with he decision. This really was a duplicate. You can add your solution to the prior questions if you would like to get it out there. – Yrb Aug 02 '21 at 15:50
  • @Yrb this is not a duplicate, all the links have very bad answer and do not target this specific question. Please reopen, I found the solution – Arturo Aug 06 '21 at 17:03
  • @nickreps Please reopen the question, I've found the solution. The links provided are for a different question. – Arturo Aug 06 '21 at 17:04
  • @Arturo I did not close the question. That may have been another user. – nickreps Aug 07 '21 at 00:45
  • Can you vote to reopen? @nickreps – Arturo Aug 07 '21 at 01:44
  • @Arturo I have flagged to have it reopened on the grounds that you have a more appropriate answer. Hope this helps! – nickreps Aug 07 '21 at 03:03
  • @nickreps I only see my vote to reopen it – Arturo Aug 07 '21 at 15:54

0 Answers0