我需要使用xcode迅速实现一个拇指指纹扫描仪。我找到了手势识别器,但是我没有对“onTouchDown”和“onTouchUp”事件做出反应的要点。

基础对象是UIImageView。我对此很陌生,因此无法找到适当的文档。

非常感谢

最佳答案

当前的iOS设备支持以下硬件:

  • 多点触控屏幕。
  • 一个主页按钮,能够读取指纹。

  • 因此,不可能在UIImageView或任何UIView上实现指纹扫描仪。但是,您可以响应触摸,多点触摸,跟踪加速度,速度,运动等。

    响应触摸事件:

    有几种方法可以响应触摸事件。

    UIButton:

    您可以将UIButton添加为子视图或视图。确保调整大小以适应父视图的边界。然后使用[button addTarget:self action:@selector(someMethod) controlEvents:UIControlEventTouchUpInside]
    使用UIPanGestureRecognizer:

    添加UIPanGestureRecognizer:
    _panHandler = [[UIPanGestureRecognizer alloc] initWithTarget:self
        action:@selector(panHandle:)];
    
    - (void)panHandle:(UIPanGestureRecognizer *)recognizer;
    {
        if ([recognizer state] == UIGestureRecognizerStateBegan) {
           //do something
        }
        else if ([recognizer state] == UIGestureRecognizerStateChanged) {
            //do something
        }
        else if ([recognizer state] == UIGestureRecognizerStateEnded) {
            //do something
        }
    }
    

    最低级别/最灵活/更多工作:

    在您的UIView子类中重写:
    - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
    {
    }
    
    
    - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
    {
    }
    
    - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
    {
    }
    

    关于ios - 使用xcode和swift在IOS中降落/升起,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26733225/

    10-09 16:26
    查看更多