HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22.06k stars 1.73k forks source link

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

Open XWXGitHub opened 3 years ago

XWXGitHub commented 3 years ago

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

Demo Project

Tang-Hai commented 2 years ago

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

ShenYj commented 2 years ago

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

Tang-Hai commented 2 years ago

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

ShenYj commented 2 years ago

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

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

coderDeviCheng commented 1 year ago

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