gpt4 book ai didi

iOS 13 UIActivityViewController 在图像保存后自动呈现以前的 VC

转载 作者:行者123 更新时间:2023-12-02 00:55:43 24 4
gpt4 key购买 nike

我正在尝试实现“将图像保存到库”功能,然后返回到当前 View Controller ,但在新的 iOS 13 上,它会返回到呈现当前 View Controller 的 View Controller :

PHPhotoLibrary.requestAuthorization({(_ status: PHAuthorizationStatus) -> Void in })

let shareItems: Array = [newImg,"Hello"] as [Any]

let activityController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)

if UIDevice.current.userInterfaceIdiom == .pad {
activityController.popoverPresentationController?.sourceView = saveButton
}

present(activityController, animated: true)

最佳答案

@KDP 解决方案的 Swift 版本:

let fakeViewController = TransparentViewController()
fakeViewController.modalPresentationStyle = .overFullScreen

activityViewController.completionWithItemsHandler = { [weak fakeViewController] _, _, _, _ in
if let presentingViewController = fakeViewController?.presentingViewController {
presentingViewController.dismiss(animated: false, completion: nil)
} else {
fakeViewController?.dismiss(animated: false, completion: nil)
}
}
present(fakeViewController, animated: true) { [weak fakeViewController] in
fakeViewController?.present(activityViewController, animated: true, completion: nil)
}

fakeViewController 要么在事件完成时关闭,要么我们需要在完成时关闭它。

关于iOS 13 UIActivityViewController 在图像保存后自动呈现以前的 VC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56903030/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com