Swift | Horizontal List

158 Views Asked by At

I tried to make an horizontal list, but when I add on delete property it doesn't work.

var body: some View{
    NavigationView {
        List {
            ScrollView(.horizontal, showsIndicators: false) {
                HStack {
                    Section(
                            header: Text("Fruits")) {
                            ForEach(fruits, id: \.self) { fruit in
                                Text(fruit.capitalized)
                            }
                            .onDelete(perform: delete)
                        }
                }
            }
                
            
        }
        .navigationTitle("Ejemplo")
        .navigationBarItems(leading: EditButton())
    }
}

func delete(indexSet: IndexSet){
    fruits.remove(atOffsets: indexSet)
}

Here it works Here it doesn't

0

There are 0 best solutions below