Skip to content

Fix table view delegate message forwarding #154

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

Merged
merged 1 commit into from
Nov 28, 2015
Merged

Fix table view delegate message forwarding #154

merged 1 commit into from
Nov 28, 2015

Conversation

anatols
Copy link
Contributor

@anatols anatols commented Nov 26, 2015

I've encountered an issue with message forwarding on my iPad (Mini 2 iOS 8.1.3 FWIW). UITableViewDelegate methods were not called.

The root cause is that UITableView caches the results of respondsToSelector calls for all delegate methods and does it at the very moment when a new delegate is set. Thus, it happened when the delegate was set from commonInit, and at that moment self.tableViewDelegate was still nil. Later on, since the delegate was set to the same instance (self) in setTableViewDelegate, UITableView skipped updating that cache and was assuming all methods to be still not implemented, no calls were made, and the table was not interactable.

Resetting the delegate on UITableView first before setting it forced it to refresh the cache and calls were then received as expected.

I've encountered an issue with message forwarding on my iPad (Mini 2 iOS 8.1.3 FWIW). UITableViewDelegate methods were not called.

The root cause is that UITableView caches the results of respondsToSelector calls for all delegate methods and does it at the very moment when a new delegate is set. Thus, it happened when the delegate was set from commonInit, and at that moment self.tableViewDelegate was still nil. Later on, since the delegate was set to the same instance (self) in setTableViewDelegate, UITableView skipped updating that cache and was assuming all methods to be still not implemented, no calls were made, and the table was not interactable.

Resetting the delegate on UITableView first before setting it forced it to refresh the cache and calls were then received as expected.
@Augustyniak
Copy link
Owner

Thanks for contribution!

Augustyniak added a commit that referenced this pull request Nov 28, 2015
Fix table view delegate message forwarding
@Augustyniak Augustyniak merged commit 0a55279 into Augustyniak:master Nov 28, 2015
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

Successfully merging this pull request may close these issues.

2 participants