Reject UISwipeActionsConfiguration by checking back

I implemented the final actions using the new iOS 11 API UISwipeActionsConfiguration, and I can reveal them by scrolling from the edge, I can carry it all the way to the left, etc.

But I can not hide these actions, returning to its original position. If I drag a little to the left and then go back to the right, it will reject (see Gif). He also deviates by clicking on the cell.

The official Mail app supports dragging and dropping to hide deletion actions, so it can be in the API too.

See a sample project here: https://github.com/nezhyborets/ios-case-study-playgrounds/tree/master/UISwipeActionsConfiguration

enter image description here

+4
source share
1 answer

Great question!

, leading trailing:

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let action = UIContextualAction(style: .normal, title: "bla") { (action, view, success) in
        success(true)
    }
    return UISwipeActionsConfiguration(actions: [action])
}

.

, . actions [], .

+2

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


All Articles