From e2395692f53a2d80138db8d02151f0d440a3dacd Mon Sep 17 00:00:00 2001 From: "Choshim.Wei" Date: Fri, 22 Aug 2025 15:35:26 +0800 Subject: [PATCH 1/2] feat: Whether to distinguish iPad special layout, the default is false --- PanModal/Presenter/PanModalPresenter.swift | 1 + PanModal/Presenter/UIViewController+PanModalPresenter.swift | 4 +++- PanModalDemo.xcodeproj/project.pbxproj | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PanModal/Presenter/PanModalPresenter.swift b/PanModal/Presenter/PanModalPresenter.swift index 8763fdac..0aea7b20 100644 --- a/PanModal/Presenter/PanModalPresenter.swift +++ b/PanModal/Presenter/PanModalPresenter.swift @@ -32,6 +32,7 @@ protocol PanModalPresenter: AnyObject { func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView?, sourceRect: CGRect, + shouldSeparateForPad: Bool, completion: (() -> Void)?) } diff --git a/PanModal/Presenter/UIViewController+PanModalPresenter.swift b/PanModal/Presenter/UIViewController+PanModalPresenter.swift index b252d8f7..f3ad8987 100644 --- a/PanModal/Presenter/UIViewController+PanModalPresenter.swift +++ b/PanModal/Presenter/UIViewController+PanModalPresenter.swift @@ -35,6 +35,7 @@ extension UIViewController: PanModalPresenter { - viewControllerToPresent: The view controller to be presented - sourceView: The view containing the anchor rectangle for the popover. - sourceRect: The rectangle in the specified view in which to anchor the popover. + - shouldSeparateForPad: Whether to distinguish iPad special layout, the default is false - completion: The block to execute after the presentation finishes. You may specify nil for this parameter. - Note: sourceView & sourceRect are only required for presentation on an iPad. @@ -42,13 +43,14 @@ extension UIViewController: PanModalPresenter { public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView? = nil, sourceRect: CGRect = .zero, + shouldSeparateForPad: Bool = false, completion: (() -> Void)? = nil) { /** Here, we deliberately do not check for size classes. More info in `PanModalPresentationDelegate` */ - if UIDevice.current.userInterfaceIdiom == .pad { + if UIDevice.current.userInterfaceIdiom == .pad, shouldSeparateForPad { viewControllerToPresent.modalPresentationStyle = .popover viewControllerToPresent.popoverPresentationController?.sourceRect = sourceRect viewControllerToPresent.popoverPresentationController?.sourceView = sourceView ?? view diff --git a/PanModalDemo.xcodeproj/project.pbxproj b/PanModalDemo.xcodeproj/project.pbxproj index 0fe4e141..c9ec9f68 100644 --- a/PanModalDemo.xcodeproj/project.pbxproj +++ b/PanModalDemo.xcodeproj/project.pbxproj @@ -830,7 +830,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6UF7FN999R; + DEVELOPMENT_TEAM = XP3H66JF79; INFOPLIST_FILE = "$(SRCROOT)/Sample/Resources/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -851,7 +851,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6UF7FN999R; + DEVELOPMENT_TEAM = XP3H66JF79; INFOPLIST_FILE = "$(SRCROOT)/Sample/Resources/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( From b83c2bb9d98eff391dfc1e82c72929fc3d9fe1fa Mon Sep 17 00:00:00 2001 From: "Choshim.Wei" Date: Fri, 22 Aug 2025 18:15:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=AE=B9=E5=99=A8=E5=8F=AF=E8=83=BD=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PanModal/Controller/PanModalPresentationController.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PanModal/Controller/PanModalPresentationController.swift b/PanModal/Controller/PanModalPresentationController.swift index 11fb2a6e..83756d2c 100644 --- a/PanModal/Controller/PanModalPresentationController.swift +++ b/PanModal/Controller/PanModalPresentationController.swift @@ -176,7 +176,11 @@ open class PanModalPresentationController: UIPresentationController { guard let containerView = containerView else { return } - + + if self.panContainerView.frame == .zero { + self.adjustPresentedViewFrame() + } + layoutBackgroundView(in: containerView) layoutPresentedView(in: containerView) configureScrollViewInsets()