开发者

UITableView trailingSwipeActionsConfigurationForRowAt not working on iOS 14.4 simulator

开发者 https://www.devze.com 2022-12-07 21:40 出处:网络
I\'m building an app that needs to use trailing actions for a UITableView,开发者_如何学C I configured trailingSwipeActionsConfigurationForRowAt as follows:

I'm building an app that needs to use trailing actions for a UITableView,开发者_如何学C I configured trailingSwipeActionsConfigurationForRowAt as follows:

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        if indexPath == IndexPath(row: 0, section: 0) {
            return nil
        }

        let deleteAction = UIContextualAction(style: .normal, title: "") { [weak self] (_, _, completion) in
            self?.onDeleteActionClicked(at: indexPath)
            completion(true)
        }
        deleteAction.backgroundColor = .black
        deleteAction.image = UIImage.sfSymbol(.trash, tintColor: .white)

        let editAction = UIContextualAction(style: .normal, title: "") { [weak self] (_, _, completion) in
            self?.onEditActionClicked(at: indexPath)
            completion(true)
        }
        editAction.backgroundColor = .white
        editAction.image = UIImage.sfSymbol(.edit)

        let configuration = UISwipeActionsConfiguration(actions: [deleteAction, editAction])
        configuration.performsFirstActionWithFullSwipe = false
        return configuration
    }

This implementation works on a physical device and other simulators running iOS 16.1

The delegate is set correctly since didSelectRowAt is being called, no gestureRecognizers are added to the cells and seems to be working fine with simulators running iOS 16.1 and physical devices running the same iOS version

0

精彩评论

暂无评论...
验证码 换一张
取 消