Bug 20592 - GetHeightForRow not called when using TableView.Scrolled event
Summary: GetHeightForRow not called when using TableView.Scrolled event
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-06-14 12:42 UTC by Christian Rishøj
Modified: 2014-06-16 05:24 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Minimal reproduction of the problem (10.97 KB, application/zip)
2014-06-14 12:42 UTC, Christian Rishøj
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Christian Rishøj 2014-06-14 12:42:33 UTC
Created attachment 7073 [details]
Minimal reproduction of the problem

Description of Problem:

In a UITableViewController subclass, I normally use GetHeightForRow to implement dynamically sized cells. This works fine, until I register an event listener using TableView.Scrolled += (...). As soon as I do this, GetHeightForRow is no longer called.

Steps to reproduce the problem:
1. Run the attached minimal project
2. Observe that the rows are sized dynamically
3. Uncomment the event listener in the controller's ViewDidLoad method and run again
4. Observe that the rows now have fixed height


/Users/christian/Projects/SizeForCellAtIndexPathTest.zip
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-06-16 05:24:06 UTC
This is a variation of the Xamarin.iOS limitation where you can't use the Objective-C delegate logic and C# events at the same time [1]

What happens is managed events (TableView.Scrolled) uses the [Weak]Delegate property under the hood, but in this case Objective-C has set the WeakDelegate to the TestTableViewController instance (which is what's driving the GetHeightForRow overload to actually work). So when you attach to the Scrolled event, you end up setting WeakDelegate to something else, thus breaking GetHeightForRow.

Here's a potential solution: http://stackoverflow.com/a/17474025/183422

[1] http://spouliot.wordpress.com/2012/03/26/events-vs-objective-c-delegates/