SCLAlertView-Swift icon indicating copy to clipboard operation
SCLAlertView-Swift copied to clipboard

Taps on buttons not handled after device rotation

Open sabiland opened this issue 9 years ago • 4 comments

It sometimes happens that if you:

  • show alert -> rotate device -> taps on buttons are not handled anymore.

sabiland avatar Mar 04 '16 08:03 sabiland

Had the same issue - start with landscape mode and then you go to portrait mode while alert is present the cancel button doesn't work anymore. It seems like the last button does not register. This occurs when you have at least 2 buttons.

Abstract45 avatar Sep 12 '16 07:09 Abstract45

👍 Confirmed

Aximem avatar Dec 13 '16 20:12 Aximem

I have two buttons in an alert and neither work after rotating. This happens from portrait -> landscape and landscape -> portrait. Rotating back to the original orientation allows the buttons to work again.

If you set clipToBounds on all subviews, you can see that the alert view gets sized improperly. And since taps outside of the view bounds aren't processed, the buttons seem to be ignoring touches.

If you start portrait and rotate landscape, the right side cuts off half way. If you start landscape and rotate portrait, the bottom half is cut off half way. In the first case, you can still see parts of the buttons and those visible parts do, in fact, work when tapped.

nfranke avatar Jul 06 '18 20:07 nfranke

I believe the problem is that the library doesn't set the autoresizingMask. If you add this code after showing a view, everything works just fine:

        for sv in alertView.view.subviews {
            sv.autoresizingMask = [ .flexibleHeight, .flexibleWidth ]
        }

There only a single subview, which I'd imagine is the baseView instance variable, but it's inaccessible.

nfranke avatar Jul 06 '18 21:07 nfranke