Explorar o código

URLHandler: Handle presentation of alert correctly

The presentation should at least be handled by the rootViewController.

Closes #677
Soomin Lee %!s(int64=5) %!d(string=hai) anos
pai
achega
05136d6b5a
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      Sources/URLHandler.swift

+ 8 - 1
Sources/URLHandler.swift

@@ -181,7 +181,14 @@ public class VLCCallbackURLHandler: NSObject, VLCURLHandler {
                 self.play(url: transformedURL, completion: nil)
             }
             alert.addAction(playAction)
-            alert.show(UIApplication.shared.keyWindow!.rootViewController!, sender: nil)
+
+            var rootViewController = UIApplication.shared.keyWindow?.rootViewController
+            if let tabBarController = UIApplication.shared.keyWindow?.rootViewController
+                as? UITabBarController {
+                rootViewController = tabBarController.selectedViewController
+            }
+            rootViewController?.present(alert, animated: true, completion: nil)
+
         } else {
             self.play(url: transformedURL, completion: nil)
         }