Skip to content

Commit 327ffc5

Browse files
authored
fix(ios): don't use the tmpWindow on popover presentation (#2714)
1 parent 6a03960 commit 327ffc5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

ios/Capacitor/Capacitor/CAPBridge.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,20 @@ enum BridgeError: Error {
598598
}
599599

600600
@objc public func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
601-
self.tmpWindow.makeKeyAndVisible()
602-
self.tmpVC.present(viewControllerToPresent, animated: flag, completion: completion)
601+
if viewControllerToPresent.modalPresentationStyle == .popover {
602+
self.viewController.present(viewControllerToPresent, animated: flag, completion: completion)
603+
} else {
604+
self.tmpWindow.makeKeyAndVisible()
605+
self.tmpVC.present(viewControllerToPresent, animated: flag, completion: completion)
606+
}
603607
}
604608

605609
@objc public func dismissVC(animated flag: Bool, completion: (() -> Void)? = nil) {
606-
self.tmpVC.dismiss(animated: flag, completion: completion)
610+
if self.tmpWindow.isHidden {
611+
self.viewController.dismiss(animated: flag, completion: completion)
612+
} else {
613+
self.tmpVC.dismiss(animated: flag, completion: completion)
614+
}
607615
}
608616

609617
}

ios/Capacitor/Capacitor/Plugins/Browser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class CAPBrowserPlugin : CAPPlugin, SFSafariViewControllerDelegate {
2323
self.vc = SFSafariViewController.init(url: url!)
2424
self.vc!.delegate = self
2525
let presentationStyle = call.getString("presentationStyle")
26-
if presentationStyle != nil && presentationStyle == "popover" {
26+
if presentationStyle != nil && presentationStyle == "popover" && UIDevice.current.userInterfaceIdiom == .pad {
2727
self.vc!.modalPresentationStyle = .popover
2828
self.setCenteredPopover(self.vc)
2929
} else {

0 commit comments

Comments
 (0)