【问题标题】:disable swipe gesture for iCarousel禁用 iCarousel 的滑动手势
【发布时间】:2015-06-23 07:07:42
【问题描述】:

我正在使用 iCarousel 显示一组图像,并且我想禁用滑动手势。我在文档中没有找到。不确定这是否可行

【问题讨论】:

  • 那么您想以编程方式更改图像吗?

标签: ios swipe-gesture icarousel


【解决方案1】:

如果您想禁用滑动手势,那么我想您是否想要以编程方式更改图像。

非常简单地禁用轮播的用户交互。

如果您使用情节提要,则只需删除 User Inreaction Enabled 的复选标记

如果您通过代码使用,则使用以下代码禁用User Inreaction Enabled

yourcarousel.userInteractionEnabled = FALSE;

希望这对解决您的问题有很大帮助。

【讨论】:

    【解决方案2】:

    @Junchao GU 如果你正在使用

    https://github.com/nicklockwood/iCarousel

    他们正在使用点击手势和平移手势 你必须评论

        UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)];
    panGesture.delegate = (id <UIGestureRecognizerDelegate>)self;
    [_contentView addGestureRecognizer:panGesture];
    
    //add tap gesture recogniser
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap:)];
    tapGesture.delegate = (id <UIGestureRecognizerDelegate>)self;
    [_contentView addGestureRecognizer:tapGesture];
    

    在 iCarousel.m 文件中

    希望对你有帮助

    【讨论】:

    • 但是这段代码不会禁用我想要的自动滚动效果吗?
    • 好的。很确定这会起作用,但是直接更改源代码对我来说并不是一个好主意。但是谢谢:)
    • 我多次更改源代码以使其与我的应用程序兼容。始终备份主要源代码,然后对其进行更改。
    【解决方案3】:

    更改 iCarousel 的源代码是个坏主意。我认为接下来最好做:

    carouselView.contentView.gestureRecognizers?.removeAll()
    

    希望对某人有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多