Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 view.hero.id present到二级页面,然后二级页面实现UIPanGestureRecognizer功能,会造成页面卡死 #723

Open
XWXGitHub opened this issue Sep 3, 2021 · 5 comments

Comments

@XWXGitHub
Copy link

What did you do?

从一级页面present到二级页面时,在二级页面实现
view.hero.id = ****
self.isHeroEnabled = true 并且还在二级页面设置UIPanGestureRecognizer侧滑手势,

@objc func slide(pan: UIPanGestureRecognizer) {
let translationX = pan.translation(in: pan.view).x
if translationX > 0 {
// 向右平移滑动
let progress = translationX / (ScreenW / 3)
switch pan.state {
case .began:
dismiss(animated: true)
case .changed:
Hero.shared.update(progress)

            let position = CGPoint(x: translationX + view.center.x, y: pan.translation(in: pan.view).y + view.center.y)
            Hero.shared.apply(modifiers: [.position(position)], to: view)
        default:
            if progress + pan.velocity(in: pan.view).x > 0.5 {
                Hero.shared.finish()
            } else {
                Hero.shared.cancel()
            }
        }
    }
}

What did you expect to happen?

我以为能够正常侧滑返回一级页面.

What happened instead?

最后发现slide方法正常执行,但侧滑功能失效,然后返回一级页面时整个APP就卡死了. 然而不知道为什么模拟器测试是没有任何问题一切正常.

General Information

  • Hero Version:

  • iOS Version(s): 14.0

  • Swift Version: 5.4.2

  • Devices/Simulators: Devices

  • Reproducible in Examples? (Yes/No): NO

Demo Project

@Tang-Hai
Copy link

我也遇到了这个问题,请问你现在解决了没

@ShenYj
Copy link

ShenYj commented May 23, 2022

某些情况下iPhone正常,iPad会崩溃

@Tang-Hai
Copy link

把 finish cancel 等操加个 DispatchQueue.main.async { } ,可以解决问题

@ShenYj
Copy link

ShenYj commented May 25, 2022

把 finish cancel 等操加个 DispatchQueue.main.async { } ,可以解决问题

谢谢分享,以后再用遇到试试

@coderDeviCheng
Copy link

我也遇到这个问题了,我是push到次级页面,实现手势下拉返回,有一定几率页面卡死

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants