Closed StefaniOSApps closed 6 years ago
How can we check if a UITableViewCell is moving in scrolling view ? @andreamazz
I think the solution we can found in
open func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer else { return true }
let velocity = gestureRecognizer.velocity(in: gestureRecognizer.view)
return abs(velocity.y) > abs(velocity.x)
}
how can we can proof if a UITableViewCell is moving ?
Checkout latest commit
Reopen it
if let tableView = scrollableView as? UITableView, tableView.isEditing {
return
}
it is not the best solution, because the UITableView with tableView.isEditing = true, does not allow to hide the NavBar (always).
I hope you know that tableView.isEditing is not the same one as moving UITableViewCell It must be asked directly if a cell is being moved at this moment
i have been updated the demo project with the current solution
https://github.com/StefaniOSApps/Example check it out
I preferred this route for a reason: it's a common pattern to have the button to end the editing mode in the navigation bar, it might be annoying to force the user to scroll down to make it visible. It's safe to assume that during the editing phase, having the navigation bar visible is preferred.
I have the problem that I want to slide a cell in a section to delete and move in another section cells with each other.
Can you make it optional? That would be the best way.
showAlwaysNavigationBarWhileEditingmode = true / false
I could, but the starting issue remains, I'm not aware of a public API that tells you whether a cell is being dragged or not. I'll do some digging and let you know.
Maybe checking if a single cell is both in editing and highlighted? 🤔
I had already tested everything. I also checked the alpha value of the cell subviews, but without success.
I have solved this problem:
ADD
/**
Defaults to `true`
*/
open var showAlwaysNavigationBarWhileEditing = true
CHANGED
if let tableView = scrollableView as? UITableView, tableView.isEditing, showAlwaysNavigationBarWhileEditing {
return
}
SET
[(ScrollingNavigationController *)self.navigationController setShowAlwaysNavigationBarWhileEditing:true];
i have been updated the demo project with the current solution
https://github.com/StefaniOSApps/Example check it out
That's fine, but if the library user doesn't set that flag, the editing behavior will be broken like in your starting project. I rather have a more robust solution, I'll let you know if I can find it, if I can't I'll add that flag.
No, I do not think so. The function gestureRecognizer?.cancelsTouchesInView = false
is already enough, so that everything works.
The user can set [ScrollingNavigationController setShowAlwaysNavBarWhileEditing:true]
in his own Project (default is true).
I think this solution is the best and my fork (branch master) use this way.
Ok, sounds reasonable. Added shouldScrollWhenTableviewIsEditing
in the latest commit.
thanks
Describe the bug You can not move rows in UITableview
Demo Project https://github.com/StefaniOSApps/Example Run Demo
Expected behavior Can move rows to each position.