Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI - Drag and drop reorder on iPad works without EditMode?

Tags:

swiftui

In SwiftUI, if you have a list you need to enable edit mode to get the reorder control to appear so you can reorder the rows (assuming you have added the .onMove modifier).

On iPad, you can reorder the rows without enabling EditMode, which stops any long press gestures from working.

Why is this behaviour so different, and is there a way to get the iPad to behave the same as iPhone?

TIA.


1 Answers

You can conditionally disable reordering to enable recognition of long press gesture on a row:

.onMove(perform: isEditing.wrappedValue ? move(from:to:) : nil)

where isEditing is a boolean binding to EditMode.

like image 129
jbaraga Avatar answered Dec 06 '25 17:12

jbaraga