gpt4 book ai didi

ios - popViewController(动画 : true) animation works slow

转载 作者:行者123 更新时间:2023-11-28 07:42:35 26 4
gpt4 key购买 nike

我在 imageView 上添加了一个点击手势识别器,所以当用户点击下面的图像时,函数就会被调用。

@objc func handleTap(_ sender: UITapGestureRecognizer) {

self.navigationController?.popViewController(animated: true)
}

当我推送到详细 View Controller 时,动画看起来不错并且工作流畅,但是当我使用上述方法 popViewController(animated: true) 时,动画不是那么流畅,甚至可能会卡住一秒钟。

我还使用 viewWillAppear 和 viewWillDisappear 方法在详细 View Controller 中隐藏导航栏。我读到这可能会导致动画运行缓慢,但仍然无法找到解决方法。

  override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = true
}

override func viewDidDisappear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = false
}

最佳答案

试试这个,我不确定,但它可能有效

DispatchQueue.main.async {
self.navigationController?.popViewController(animated: true)
}

关于ios - popViewController(动画 : true) animation works slow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51857425/

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