1

I have a framework which based on user actions shows alert messages by adding webview on top of the current top view. Prior to iOS 13 and multiple scene support, I use to fetch the top view using following code

UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;

        while (topController.presentedViewController) {
            topController = topController.presentedViewController;
        }

and then add webview on top of it. But now since iPad can have multiple scenes, above code always gives only the last created scene as topview. Being a framework I wanted to give freedom to app to decide on which scene it would like to show the message by somehow identifying scene which performed that action or by keeping track of which scene performed last activity in the framework.

Basically Loop through all the scenes in the foreground active state and match with some identifier to identify on which scene webview should be added.

Any help will be appreciated.

user1169079
  • 3,003
  • 5
  • 37
  • 69
  • Does this answer your question? [Getting currently focused UIScene when multiple connected scenes are active in foreground](https://stackoverflow.com/questions/57679284/getting-currently-focused-uiscene-when-multiple-connected-scenes-are-active-in-f) – Rivera Apr 21 '20 at 21:59

0 Answers0