'SwiftUI List rows in Edit Mode do not allow Buttons actions/NavigationLinks to work?
SwiftUI List rows in Edit Mode do not allow Buttons actions to work I note (as well as NavigationLinks too). Is there a way to get this working?
Goal - Want to have NavigationLink or Modal view to the following depending on the edit mode. This relies on the ability to have button actions/nav links working in Edit Mode. (if there's another way to achieve my goal happy to have pointers)
- Not Edit Mode: Click on row => Detailed view for this record
- In Edit Mode: Click on row => Edit view for the master record name (e.g. rename)
Code (just to highlight the button doesn't work in Edit Mode):
List() {
ForEach(gcLists) { gcList in
HStack {
Button(gcList.title) {
print("button pressed!")
}
}
}
.onDelete(perform: deleteList)
.onMove(perform: move)
}
Solution 1:[1]
I used previously the following approach, please try
Button(action: {}) {
// label content here
}
.onTapGesture {
// action here
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Asperi |