How to enable UIDragInteraction in custom UIViews for iPhone

I am trying to use the new Apple API to enable Drag interactions in custom UIViews. I managed to get it to work when testing using the iPad, but when I run the same application on my iPhone 7 - ios 11 beta 3, I cannot drag my custom UIViews.

I noticed that we need to enable drag and drop interaction when used in UICollectionView and UITableViews

collectionView.dragInteractionEnabled = true tableView.dragInteractionEnabled = true

but I can’t find anything in the documentation or anywhere to include it in custom UIViews to make it work on the iPhone. Does anyone know a way to enable drag and drop interaction for custom UIViews for iPhone?

thank

+2
source share
1 answer
let dragInteraction: UIDragInteraction = ...
dragInteraction.isEnabled = true

view.addInteraction(dragInteraction)

check this

UIDragInteraction.isEnabledByDefault https://developer.apple.com/documentation/uikit/uidraginteraction/2891051-isenabledbydefault

+2
source

Source: https://habr.com/ru/post/1686302/


All Articles