瀏覽代碼

URLHandler: Handle presentation of alert correctly

The presentation should at least be handled by the rootViewController.

Closes #677
Soomin Lee 5 年之前
父節點
當前提交
05136d6b5a
共有 1 個文件被更改,包括 8 次插入1 次删除
  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)
         }