Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Calling delegate methods in other queue delays rendering UITableView #65

Open
ngs opened this issue Jan 23, 2016 · 2 comments
Open

Calling delegate methods in other queue delays rendering UITableView #65

ngs opened this issue Jan 23, 2016 · 2 comments

Comments

@ngs
Copy link
Contributor

ngs commented Jan 23, 2016

I'm using RealmResultsControllerDelegate as UITableViewDataSource.

When beginning table view while scrolling, I see blank until stop scrolling.

01

I could fix this by updating table view in didChangeObject at once like:

func didChangeResults(controller: AnyObject) {
    guard controller === self.rrc else { return }
    tableView.beginUpdates()
    pendingChanges.forEach { update in
        if let newIndexPath = update.newIndexPath, oldIndexPath = update.oldIndexPath {
            switch update.changeType {
            case .Delete:
                tableView.deleteRowsAtIndexPaths([newIndexPath], withRowAnimation: .Automatic)
                break
            case .Insert:
                tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Automatic)
                break
            case .Move:
                tableView.deleteRowsAtIndexPaths([oldIndexPath], withRowAnimation: .Automatic)
                tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Automatic)
                break
            case .Update:
                tableView.reloadRowsAtIndexPaths([newIndexPath], withRowAnimation: .Automatic)
                break
            }
        } else if let sectionIndex = update.sectionIndex {
            let indexSet = NSIndexSet(index: sectionIndex)
            switch update.changeType {
            case .Delete:
                tableView.deleteSections(indexSet, withRowAnimation: .Automatic)
                break
            case .Insert:
                tableView.insertSections(indexSet, withRowAnimation: .Automatic)
                break
            case .Update:
                tableView.reloadSections(indexSet, withRowAnimation: .Automatic)
                break
            default:
                break
            }
        }
    }
    pendingChanges.removeAll()
    tableView.endUpdates()
}

source

I think we should not call delegate method callbacks in different queues.

ref: ngs/ci2go#33

@polqf
Copy link
Owner

polqf commented Feb 11, 2016

Hi @ngs ,

I think I don't quite get what you say it is the source of the issue...

I think we should not call delegate method callbacks in different queues.

All the calls to the delegate methods occur on the main thread. So maybe the source of the problem is not that. Do you have more information about it?

BTW, sorry for the delay on replying to this issue

@polqf
Copy link
Owner

polqf commented Feb 11, 2016

Just cloned your repo, checked out this commit: ngs/ci2go@bf10a1c , which is the one before the ngs/ci2go#33 PR was applied, and I am not having the issue you were showing me on the gif 😕

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants