Search code examples
objective-cportraitdevice-orientationunrecognized-selector

unrecognized selector sent to instance on deviceOrientationDidChange


Right now my app should only supports Portrait. On Summary/Supported Device Orientations I have only selected Portrait so I'm hoping that my app will not rotate. I was testing the app on a device and suddenly I'm getting the following error randomly:

[UIButtonContent deviceOrientationDidChange:]: unrecognized selector sent to instance

It happens when I rotate the device SOMETIMES, is not consistent, and is not always over UIBUttonContent. I supposed that if I only select Portrait, deviceOrientationDidChange should not be called or should be ignored.

Other times my app crashes with an EXC_BAD_ACCESS (code=1, address=something) but it happens when I rotate the device so I'm guessing that both errors are related.

I don't know what to do with this, it's hard to debug because I don't have feedback, the All Exceptions Breakpoint is not being called, so I don't know where and exactly why this is happening. Any idea on how to debug this is welcome.


Solution

  • I solved this issue a long time ago, but I think is good to share what actually helped me on this case.

    After trying everything with no results with Instruments I started debugging old-school. I had an idea of "where" the error was so I just commented all the code on that section. I was right, the bug just disappeared along with some functionalities. After that I made "binary uncommenting" (uncomment one half) till I got the bug line. It was a third party library, I had an object that was not being released properly.