spicyShrimp / U17

精仿有妖气漫画(Swift5)
MIT License
1.03k stars 243 forks source link

在TabbarController下的控制器中添加轮播控件,从左向右划时崩溃 #9

Closed LockLight closed 5 years ago

LockLight commented 6 years ago

首先非常感谢分享Demo,目前看到的结构最清晰的swift4 Demo.

下面描述一下我的问题,崩溃信息如下,

UNavigationController 0x7fee7d04f600> valueForUndefinedKey:]: this class is not key value coding-compliant for the key __isTransitioning.'

使用了项目中的UNavigationController基类,应该是轮播的左划与导航栏的左划返回手势冲突,注释下面的extension后不会崩溃了,请问有什么更好的处理办法吗

`extension UINavigationController:UIGestureRecognizerDelegate{

public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
    let isLeftToRight = UIApplication.shared.userInterfaceLayoutDirection == .leftToRight
    guard let ges = gestureRecognizer as? UIPanGestureRecognizer else {
        return true
    }
    if ges.translation(in: gestureRecognizer.view).x * (isLeftToRight ? 1 : -1) <= 0
        || value(forKey: "__isTransitioning") as! Bool
        || disablePopGesture{
        return false
    }
    return viewControllers.count != 1
}

}`

spicyShrimp commented 5 years ago

this class is not key value coding-compliant for the key __isTransitioning.'

spicyShrimp commented 5 years ago

swift下找不到这个key了 把这个||删除就可以了 if ges.translation(in: gestureRecognizer.view).x * (isLeftToRight ? 1 : -1) <= 0 || disablePopGesture{ return false }