我有一个pageMenuController
,当我左右滑动时,我需要检测其移动方向。我的委托方法是:
func pageMenuController(_ pageMenuController: PageMenuController, didScrollToPageAtIndex index: Int, direction: PageMenuNavigationDirection) {
print(index)
// The page view controller will begin scrolling to a new page.
}
func pageMenuController(_ pageMenuController: PageMenuController, willScrollToPageAtIndex index: Int, direction: PageMenuNavigationDirection) {
}
func pageMenuController(_ pageMenuController: PageMenuController, scrollingProgress progress: CGFloat, direction: PageMenuNavigationDirection) {
}
func pageMenuController(_ pageMenuController: PageMenuController, didSelectMenuItem index: Int, direction: PageMenuNavigationDirection) {
}
我正在添加我的代码以检测willScrollToPageAtIndex
中的直接位置。如下所示:
func pageMenuController(_ pageMenuController: PageMenuController, willScrollToPageAtIndex index: Int, direction: PageMenuNavigationDirection) {
print(index)
print(PageMenuNavigationDirection.forward)
print(PageMenuNavigationDirection.self)
print(direction.hashValue)
print(direction.rawValue)
print(direction)
}
没有任何值像正向或反向打印。我的PageMenuNavigationDirection
类是这样的:
import Foundation
@objc public enum PageMenuNavigationDirection: Int {
/// Forward direction. Can be right in a horizontal orientation or down in a vertical orientation.
case forward
/// Reverse direction. Can be left in a horizontal orientation or up in a vertical orientation.
case reverse
}
extension EMPageViewControllerNavigationDirection {
var toPageMenuNavigationDirection: PageMenuNavigationDirection {
switch self {
case .forward:
return .forward
default:
return .reverse
}
}
}
任何想法,当我左右滑动时如何获得指示?