我开发了一个应用程序,允许用户在画布上绘制他的手指签名。 此功能是使用UIPanGestureRecognizer实现的,具有在UIView中绘制线条的特定目标操作,但是当“Voice Over”处于活动状态时,手势识别器操作不再被触发。
手势初始化代码
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
pan.maximumNumberOfTouches = pan.minimumNumberOfTouches = 1;
[self addGestureRecognizer:pan];
手势动作代码
- (void)pan:(UIPanGestureRecognizer *)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];
}
有没有办法在视图中使用“Voice Over”激活的手势绘制一条线?
谢谢和问候!
答案 0 :(得分:1)
我解决了我的问题设置UIView画布的isAccessibilityElement和accessibilityTraits属性:
canvasView.isAccessibilityElement = YES;
canvasView.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction;