Fix image preview presentation when order source sheet is open.
Present previews from the top of the presentation chain so tapping lead images inside the sheet no longer conflicts with the already-presented picker. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -119,6 +119,30 @@ class BaseViewController: UIViewController {
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
/// 沿 presentation 链找到当前最顶层控制器,避免 Sheet 已展示时 present 冲突。
|
||||
func topMostPresentedViewController() -> UIViewController {
|
||||
var top: UIViewController = self
|
||||
while let presented = top.presentedViewController {
|
||||
top = presented
|
||||
}
|
||||
return top
|
||||
}
|
||||
|
||||
/// 在当前可见 presentation 链顶端弹出页面。
|
||||
func presentOnTop(
|
||||
_ viewController: UIViewController,
|
||||
animated: Bool = true,
|
||||
completion: (() -> Void)? = nil
|
||||
) {
|
||||
topMostPresentedViewController().present(viewController, animated: animated, completion: completion)
|
||||
}
|
||||
|
||||
/// 全屏预览网络图片。
|
||||
func presentImagePreview(imageURLs: [String], startIndex: Int) {
|
||||
guard !imageURLs.isEmpty else { return }
|
||||
presentOnTop(ImagePreviewViewController(imageURLs: imageURLs, startIndex: startIndex))
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
private func registerBaseNotifications() {
|
||||
|
||||
Reference in New Issue
Block a user