recherche

Maison  >  Questions et réponses  >  le corps du texte

ios - 有什么方法可以判断是否有手指放在屏幕上。

有个需求需要判断使用者是否有手指放在屏幕上。
貌似没有这样的方法。

PHP中文网PHP中文网2889 Il y a quelques jours456

répondre à tous(5)je répondrai

  • 迷茫

    迷茫2017-04-18 09:18:02

    Jugez que le runloop actuel est en mode suivi. Si c'est le cas, cela signifie qu'il y a un doigt qui touche l'écran

    répondre
    0
  • 迷茫

    迷茫2017-04-18 09:18:02

    Réécrire plusieurs méthodes de Touches, Begin et End

    répondre
    0
  • 怪我咯

    怪我咯2017-04-18 09:18:02

    • (void)touchesBegan :(NSSet<UITouch > )touches withEvent :(UIEvent *)event{

    }

    -(void)touchesEnded :(NSSet<UITouch > )touches withEvent :(UIEvent *)event {

    }

    -(void)touchesMoved :(NSSet<UITouch > )touches withEvent :(UIEvent *)event {

    }

    Je ne sais pas si c'est de cela dont parle la personne qui pose la question

    répondre
    0
  • 迷茫

    迷茫2017-04-18 09:18:02

    Ajoutez la méthode suivante dans AppDelegate.m

    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
        NSLog(@"开始触摸");
    }
    
    -(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
        NSLog(@"结束触摸");
    }

    répondre
    0
  • 高洛峰

    高洛峰2017-04-18 09:18:02

    Méthode d'écriture Swift
    Si elle est globale, ajoutez-la à AppDelegate.swift
    S'il s'agit d'une certaine vue, ajoutez-la au ViewController.swift correspondant

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        print("开始触摸")
    }
    
    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        print("结束触摸")
    }

    répondre
    0
  • Annulerrépondre