ios - 有什么方法可以判断是否有手指放在屏幕上。
PHP中文网
PHP中文网 2017-04-18 09:16:02
0
5
447

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

PHP中文网
PHP中文网

认证0级讲师

reply all(5)
迷茫

Determine whether the current runloop is in tracking mode. If so, it means a finger is touching the screen

迷茫

Rewrite several methods of Touches, Begin and End

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

}

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

}

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

}

I don’t know if this is what the questioner is talking about

迷茫

Add the following method in AppDelegate.m

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

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

Swift writing method
If it is global, add it to AppDelegate.swift
If it is a certain view, add it to the corresponding ViewController.swift

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

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
    print("结束触摸")
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template