gpt4 book ai didi

ios - 英雄过渡无效

转载 作者:行者123 更新时间:2023-11-28 12:07:44 27 4
gpt4 key购买 nike

我正在使用 the Hero library在 View Controller 之间进行转换。

第一个 View Controller :

class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var people = [Person]()
override func viewDidLoad() {
super.viewDidLoad()
hero.isEnabled = true
hero.modalAnimationType = .push(direction: .right)

}

@IBAction func handleButton(){
let view = self.storyboard?.instantiateViewController(withIdentifier: "secondVC") as! UIViewController
present(view, animated: true, completion: nil)
}
}

第二个 View Controller :

class Second: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
hero.isEnabled = true
// Do any additional setup after loading the view.
}
@IBAction func handleBackButton(){
hero.modalAnimationType = .push(direction: .left)
hero.dismissViewController()
}
}

它呈现没有任何动画的新 View 。当我关闭第二个 Controller 时,它将应用正确的动画。如何用动画呈现第二个 View ?

最佳答案

好的,找到解决方案了。在第一种情况下,我有:

@IBAction func handleButton() {
let view = self.storyboard?.instantiateViewController(withIdentifier: "secondVC") as! UIViewController
present(view, animated: true, completion: nil)
}

我必须在 View 上设置动画。

@IBAction func handleButton() {
let view = self.storyboard?.instantiateViewController(withIdentifier: "secondVC") as! UIViewController
view.hero.modalAnimationType = .push(direction: .right)
present(view, animated: true, completion: nil)
}

作品

关于ios - 英雄过渡无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49096933/

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