OGeek|极客世界-中国程序员成长平台

标题: ios - 启用 Voice Over 的手势识别器 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 22:02
标题: ios - 启用 Voice Over 的手势识别器

我开发了一个应用程序,允许用户在 Canvas 上绘制他的手指签名。 此功能是使用带有特定目标操作的 UIPanGestureRecognizer 在 UIView 中绘制一条线来实现的,但是当“Voice Over”处于事件状态时,手势识别器操作不再触发。

手势初始化代码

UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self actionselector(pan];
pan.maximumNumberOfTouches = pan.minimumNumberOfTouches = 1;
[self addGestureRecognizer:pan];

手势 Action 代码

- (void)panUIPanGestureRecognizer *)pan {
    CGPoint currentPoint = [pan locationInView:self];
    CGPoint midPoint = midpoint(previousPoint, currentPoint);

    if (pan.state == UIGestureRecognizerStateBegan)
    {
        [path moveToPoint:currentPoint];
    }
    else if (pan.state == UIGestureRecognizerStateChanged)
    {
        [path addQuadCurveToPoint:midPoint controlPoint:previousPoint];
    }

    previousPoint = currentPoint;

    [self setNeedsDisplay];
}

有没有办法在“画外音”处于事件状态时使用手势在 View 中画线?

感谢和问候!



Best Answer-推荐答案


我解决了我为 UIView Canvas 设置 isAccessibilityElement 和 accessibilityTraits 属性的问题:

canvasView.isAccessibilityElement = YES;
canvasView.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction;

关于ios - 启用 Voice Over 的手势识别器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39367650/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4