codestergit / SweetAlert-iOS

Live animated Alert View for iOS written in Swift
MIT License
2.05k stars 303 forks source link

Alert doesn't show in some cases. #1

Closed dltlr closed 9 years ago

dltlr commented 10 years ago

I had to change this line: let window = UIApplication.sharedApplication().keyWindow?.subviews.first as UIView to this (notice the .last) to get it to work for me from a modally presented view controller within an app. let window = UIApplication.sharedApplication().keyWindow?.subviews.last as UIView It seems to work, but I'm not really sure what the correct change should be.

codestergit commented 9 years ago

@dltlr I have verified and present the viewcontroller modally and it is working fine.Can you please give more details about the scenario.It will really helpful to debug the issue.

nagaho commented 9 years ago

Thanks, I had the same problem but resolved by it. It happens when transition view in showAlert's userAction.

println(UIApplication.sharedApplication().keyWindow?.subviews)

Normal: 
Optional([<UITransitionView: 0x7fdddcb7d490; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x7fddda426490>>])

Bad case:
Optional([<UITransitionView: 0x7f9c3b05b710; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x7f9c3b00d990>>, <UITransitionView: 0x7f9c3b251f10; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x7f9c3b2284c0>>])
codestergit commented 9 years ago

@nagaho @dltlr I have resolved the issue. Please reopen if you get again :)