UITableViewRowAction vs UISwipeActionsConfiguration

前端 未结 2 551
暗喜
暗喜 2021-01-11 19:35

The two APIs seem to get the same result. In which case is it better to use one over the other?

override func tableView(_ tableView: UITableView, editActions         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-11 20:14

    It does basically the same, but swipe actions are available since iOS 11 was released and have some new features:

    • You are able to set actions for trailing swipe as well as for leading swipe
    • You can set image of action action.image = UIImage(...). If there is enough space it shows image as well as title

    Also, you should use swipe actions because they are preferred and in the future updates UITableViewRowActions will be deprecated how UITableView header comment can tell us:

    Use -tableView:trailingSwipeActionsConfigurationForRowAtIndexPath: instead of this method, which will be deprecated in a future release.

提交回复
热议问题