iOS5 Stable App Crashing in iOS4.3 Simulator

2019-02-21 15:33发布

问题:

i am getting an NSInvalidArgumentException with reason: -[UITapGestureRecognizer initWithCoder:]: unrecognized selector sent to instance

my understanding was that UITapGestureRecognizers were supported in ios4.x?

is it possible to load a different xib file for sub ios5 versions?

回答1:

As @mit3z states in his comment on the original question, iOS 4.3 supports this feature only when setup up manually with code. It is not supported with Interface Builder.

Apple would have saved us all grief over this if they simply added this as a build-time warning.



回答2:

I think you have a NSCoding compliant object that is deallocated before the crash. The UITapGestureRecognizer is allocated at its address and when the disappeared object (but not its reference) tries to call initWithCoder on itself, it actually calls this method on your gestureRecognizer instead.

Then your problem comes from that deallocated object but not from your gestureRecognizer.

Be sure to retain all your IBOutlet properties.