UIScreenEdgePanGestureRecognizer无法更改方向?

时间:2018-09-04 06:48:53

标签: ios objective-c swift uigesturerecognizer uipangesturerecognizer

我为屏幕边缘(左)边缘添加了一个平移手势识别器。它在纵向模式下运作良好,但在横向方向上却无法正常工作。

override init() {
    super.init()
    //Pan Gesture for dragging Screen Edge
    let panGestureFromScreenEdge = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(panFromSide(sender:)))
    panGestureFromScreenEdge.edges = .left
    UIApplication.shared.keyWindow?.addGestureRecognizer(panGestureFromScreenEdge)

}

1 个答案:

答案 0 :(得分:2)

不要将手势识别器添加到窗口。您应该关注的最高视图是窗口的rootViewController!.view。更好的是,如果这是视图控制器代码,请将其添加到self.view