gpt4 book ai didi

ios - 共享扩展模式演示样式 iOS 13 无法正常工作

转载 作者:行者123 更新时间:2023-12-03 09:22:29 24 4
gpt4 key购买 nike

我实现了共享扩展,我想用 crossDissolve 为我的 View Controller 设置动画。 ,所以我设置了modalPresentationStyle = .overFullScreenmodalTransitionStyle = crossDissolve但它似乎不起作用。 VC 仍然从下到上出现,并带有新的 iOS 13 模态样式(不是完全全屏)。
有谁知道如何解决它?它尝试了有和没有 Storyboard。

注意:我说的不是普通的 VC 演示,而是 share extension 的演示。 ,这意味着它是另一个展示我的VC的应用程序。

最佳答案

一种方法是让系统将 View Controller 呈现为容器。
然后以模态方式呈现您的内容 View Controller 。

// this is the entry point
// either the initial viewcontroller inside the extensions storyboard
// or
// the one you specify in the .plist file
class ContainerVC: UIViewController {

// afaik presenting in viewDidLoad/viewWillAppear is not a good idea, but this produces the exact result you are looking for.
// meaning the content slides up when extension is triggered.
override func viewWillAppear() {
super.viewWillAppear()

view.backgroundColor = .clear

let vc = YourRootVC()
vc.view.backgroundColor = .clear
vc.modalPresentationStyle = .overFullScreen
vc.loadViewIfNeeded()
present(vc, animated: false, completion: nil)
}

}
然后使用内容 View Controller 显示您的 Root View Controller 及其 View 层次结构。
class YourRootVC: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

let vc = UIViewController() // your actual content
vc.view.backgroundColor = .blue
vc.view.frame = CGRect(origin: vc.view.center, size: CGSize(width: 200, height: 200))
view.addSubview(vc.view)
addChild(vc)
}

}
基本上是一个容器和一个包装器,以便控制正在显示的 View 。
资料来源:我有同样的问题。这个解决方案对我有用。

关于ios - 共享扩展模式演示样式 iOS 13 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58368092/

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