0

I am working on existing swift app written in Swift 4.0. I am getting strange issue in any of screen If I tried to use UIAlertController with UIAlertAction in form of alert or action sheet. As soon as I tap on UIAlertAction Button complete screen goes black(Blank) and I need to force quit to restart app, I am getting this on iOS 14.7.1.... I tried to use alert on Main Thread, added scene delegate as well as Deployment target is iOS 13.0 But no luck and interesting part is If I run app with Xcode everything works fine but if I tried to use app on device directly without run, getting this strange issue....Any Suggestions...

Thanks in advance....

  • can you pls share the code – Noor Ahmed Natali Aug 06 '21 at 11:23
  • func showErrorAlert(_ message: String) { let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "OK", style: .destructive, handler: nil)) self.present(alert, animated: true, completion: nil) } – Sumit Kapoor Aug 06 '21 at 12:37
  • Since your provided code does not really help to get any clues, I would suggest to investigate the problem and look for places where the app creates windows and sets the key window. This is just one suspicious location where such errors may occur due to unexpected side effects. It also could be auto layout constraints conflicts, that go crazy, or an attempt to present a view controller where the presenting view controller already has setup a presented view controller. – CouchDeveloper Aug 06 '21 at 13:45
  • @CouchDeveloper Thanks, after seeing Debug View Hierarchy I got on tap of UIAlert Action, it remove window that's why complete app goes blank, So I created new window for showing Alert. I followed this stack OverFlow Answer https://stackoverflow.com/questions/58131996/every-uialertcontroller-disappear-automatically-before-user-responds-since-ios May be it helps someone.... – Sumit Kapoor Aug 09 '21 at 05:59

1 Answers1

0

I got solution for now, after seeing Debug View Hierarchy I got on tap of UIAlertAction, it remove window that's why complete app goes blank, So I created new window for showing Alert. I followed this stack OverFlow Answer Every UIAlertController disappear automatically before user responds - since iOS 13 May be it helps someone....