Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow editing of rows #9

Open
markst opened this issue Jan 11, 2017 · 1 comment
Open

Allow editing of rows #9

markst opened this issue Jan 11, 2017 · 1 comment

Comments

@markst
Copy link
Contributor

markst commented Jan 11, 2017

I'd like to be able to enable certain rows for edibility.

@markst
Copy link
Contributor Author

markst commented Jan 11, 2017

I've tried subclassing TableRow

class EditableTableRow: TableRow {

    var allowsEdit: Bool = false
    
    var editActions: [UITableViewRowAction]?

}

Combined with an extension on TableViewModel

public extension TableViewModel {

    // MARK: UITableViewDelegate

    public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        if let row = rowForIndexPath(indexPath) as? EditableTableRow {
            return row.allowsEdit
        }
        return false
    }
    
    public func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
        if let row = rowForIndexPath(indexPath) as? EditableTableRow {
            return row.editActions
        }
        return nil
    }

However my delegate methods aren't being called

markst added a commit to Papercloud/TableViewModel that referenced this issue Jan 11, 2017
markst added a commit to Papercloud/TableViewModel that referenced this issue Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant