[SwiftUI] .swipeActions not working
When using swipeActions, it does not work if you place a other content instead of a Button.
❌ It does not work
@State private var showTranslation = false
var body: some View {
List(0..<5) {
Text("\($0)")
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Image(systemName: "plus") // ❌
}
}
.listStyle(.plain)
.translationPresentation(
isPresented: $showTranslation,
text: "테스트"
)
}
}
✅ It works
@State private var showTranslation = false
var body: some View {
List(0..<5) {
Text("\($0)")
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
// ✅
Button {
showTranslation.toggle()
} label: {
Image(systemName: "plus")
}
}
}
.listStyle(.plain)
.translationPresentation(
isPresented: $showTranslation,
text: "테스트"
)
}
}
'apple > SwiftUI, Combine' 카테고리의 다른 글
SwiftUI DynamicProperty (0) | 2024.08.14 |
---|---|
SwiftUI @FoucsState @FocusedValue @FocusedObject (0) | 2024.08.08 |
[SwiftUI] NavigationLink 화살표 없애기 (0) | 2024.03.11 |
[SwiftUI] keyboard 이벤트 핸들링 (0) | 2024.03.06 |
[SwiftUI] EqutableView (feat. POD) (0) | 2023.08.08 |