Reputation: 1
Edit: The scrolling works outside of the text.
Now I am making my first project. I can´t seem to fix this code. It won't scroll.
import SwiftUI
struct SøkView: View {
@State private var searchText = ""
var body: some View {
NavigationView {
List {
ForEach(search(texts: texts, for: searchText), id: \.self) {
text in
Text(text)
.contextMenu {
Button {
UIPasteboard.general.string = text
}
label: {
Text("Copy")
Image(systemName: "doc.on.doc")
}
}
.onLongPressGesture {
// Handle long press here, maybe show a custom menu
// or perform additional actions
print("Long pressed on \(text)")
}
}
}
.searchable(text: $searchText)
.navigationTitle("Observations")
}
}
func search(texts: [String], for searchText: String) -> [String] {
if searchText.isEmpty {
return texts
} else {
return texts.filter {
$0.localizedCaseInsensitiveContains(searchText)
}
}
}
}
Upvotes: 0
Views: 63