in iOS 15.0 Devices when implementing UItableView Drag/Drop using delegate, I am facing an issue.
UITableViewDropDelegate Methods are not called.
func tableView(_ tableView: UITableView, dropSessionDidEnter session: UIDropSession) {
//This is called
}
func tableView(_ tableView: UITableView, canHandle session: UIDropSession) -> Bool {
//This gets called
return true
}
func tableView(
_ tableView: UITableView,
dropSessionDidUpdate session: UIDropSession,
withDestinationIndexPath destinationIndexPath: IndexPath?
) -> UITableViewDropProposal {
//Does not gets called
}
/**
This delegate method is the only opportunity for accessing and loading
the data representations offered in the drag item. The drop coordinator
supports accessing the dropped items, updating the table view, and specifying
optional animations.
*/
func tableView(_ tableView: UITableView, performDropWith coordinator: UITableViewDropCoordinator) {
//Does not gets called
}
The issue only occurs in iOS 15.0 devices. OS version>15.0 it works fine.
Delegate method registered using
tableView.dragInteractionEnabled = true
tableView.dragDelegate = self
tableView.dropDelegate = self
Is there any solution to this?
Post
Replies
Boosts
Views
Activity
Environment: iOS 15.7.5
Device: iPhone 7
Problem:
When collectionview cell textview is in edit mode and keyboard is shown - it bounces up the textview position causing overlaps. Video attached.
The issue only occurs on iOS 15 version. It works well in iOS 16, 17 version.
The issue occurs when Selected keyboard language is other than English.
In ViewController i am updating collectionViewBottomConstraint when keyboard is up or down to enable scroll to the end of collectionview when keyboard is shown.
disposable += NotificationCenter.default.reactive
.notifications(forName: UIResponder.keyboardWillShowNotification)
.take(duringLifetimeOf: self)
.observeValues { [weak self] notification in
guard let self else { return }
let keyboardInfo = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey]
guard var height = (keyboardInfo as? NSValue)?.cgRectValue.height else {
OALogInfo("[SetLocationInfo][VC] height is nil")
return
}
height -= self.view.safeAreaInsets.bottom
self.collectionViewBottomConstraint.constant = -height
self.collectionViewBottomConstraint.isActive = true
}
disposable += NotificationCenter.default.reactive
.notifications(forName: UIResponder.keyboardWillHideNotification)
.take(duringLifetimeOf: self)
.observeValues { [weak self] notification in
guard let self else { return }
self.collectionViewBottomConstraint.constant = 0
self.collectionViewBottomConstraint.isActive = true
}
Tried out the project: Adopting Drag and Drop in a Table View
https://developer.apple.com/documentation/uikit/drag_and_drop/adopting_drag_and_drop_in_a_table_view
When performing drag drop continuously - it does not work.
My findings: Sometimes
optional func tableView(_ tableView: UITableView, dropSessionDidUpdate session: UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UITableViewDropProposal { }
the top delegate method never fires - although drag session is started.
Please see the attached gif at:
https://pasteboard.co/nrTlSk7g2vxq.gif
Can you please suggest what needs to be done - so drag drop reorder occurs continuously.