소스 검색

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)
         }