In method viewForZoomingInScrollView: of the delegate to my scrollview I do the seemingly innocent:
// scrollView is the parameter passed to this method
float foo = scrollView.zoomScale
Boom! Crash, hello gdb.
Is this a known bug? Should I submit it?
Cheers, Doug
It would be helpful to see the output in xcode's debugger console window. Usually when you get a crash, there is some extra information available from the debugger console (open with command-shift-R, or Run > Console in the menu). If there was an exception that caused the crash, it will say which one. In any case, you can type
bt
(for backtrace) right after a crash and see the call stack when the crash occurs.In your particular case, it's possible that you've accidentally released the
UIScrollView
object, but still have a pointer to where the old deallocated object was. This would give you a crash on the next call to any method inUIScrollView
, and sincezoomScale
is a getter accessor, it counts as a method call. The most obvious symptom of this problem would be anEXC_BAD_ACCESS
exception in the debugger console when the crash occurs.Doug thanks for that fix. Why didn't I think of that? >_<
And just as the OP said, grabbing the zoomScale property fires viewForZoomingInScrollView everytime.
Pretty much, don't use the zoomScale property inside viewForZoomingInScrollView, if you do? CRASH!!!!
As moshy said, the reason the reason this happens is because the zoomScale property involves a call to viewForZoomingInScrollview, thus causing an infinite method call.
I get this and I thought it was because accessing zoomScale ends up calling viewForZoomingInScrollView, resulting in infinite recursion.
But I'm just speculating...