I have a hierarchy of views that looks like: UIView, which contains a UIView, which contains a UIScrollView, which contains a set of xib-loaded views.
(The xib-loaded views represent the scrolling content, and are all instances of the same xib.)
When a memory warning occurs on the device (at least, that is what I think this is related to), I get an exception with the following in the stack trace:
System.MissingMethodExc开发者_如何学编程eption: No constructor found for MonoTouch.UIKit.UIScrollView+_UIScrollViewDelegate::.ctor(System.IntPtr)
I'm familiar with the troublshooting FAQ that reads: "This error is produced at runtime when the code tries to instantiate an instance of the classes that you referenced from your Interface Builder file. This means that you forgot to add a constructor that takes a single IntPtr as a parameter."
However, that isn't the case I have here - and the controller for the xib does indeed implement the constructor mentioned. And, of course, the stack trace is referring to UIScrollView - not one of my classes.
Any thoughts?
You are allowing your UIScrollView to get garbage collected, while its still present in the view heirarchy. When this happens, the hidden class we use to generate events appears to be collectable as well, and is destroyed.
You should keep a managed reference to your UIScrollView for as long as you want to keep getting events raised on it.
精彩评论