Note that there are some explanatory texts on larger screens.

plurals
  1. POEvent becomes null in MonoTouch
    primarykey
    data
    text
    <p>Hi Monotouch users, I have this strange situation where I have a custom event declared in a custom UIView like so:</p> <pre><code>public delegate void SelectionChangedHandler(SelectableView selectedView, bool selected); public event SelectionChangedHandler SelectionChanged; </code></pre> <p>I then assign to this handler in the initialize method of a viewcontroller like so:</p> <pre><code>SelectableView s; ... SelectableView.SelectionChanged += HandleSelectionChanged; </code></pre> <p>I have checked and ensured that all the necessary objects still exist in memory and have not been garbage collected.</p> <p>I am finding that the event becomes null sometime between the assignment and the drawing. Has anybody come across this issue before? Or am I doing something obviously wrong in my use of events in MonoTouch?</p> <p><strong>EDIT:</strong> Some additional information - the UIView is loaded from a xib file. I just tried with a UIView not loaded from a xib and everything works fine :| I am a little dumbfounded.</p> <p><strong>EDIT 2:</strong> Even more information: All the properties set on the UIView loaded from the xib appear to become null as well! Here is the code I use to load the UIView from the xib:</p> <pre><code>var v = new SelectableView(NSBundle.MainBundle.LoadNib("SelectableView", this, null).ValueAt(0)); </code></pre> <p>I then set a property on v:</p> <pre><code>v.SomeProperty = s; </code></pre> <p>By render time SomeProperty is null.</p> <p>Cheers Naren</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload