学习笔记9—IOS触摸事件监听和操作
-(void)manageTouches:(NSSet *)touches{ for (UITouch *touch in touches) { switch (touch.phase) { caseUITouchPhaseBegan: NSLog(@"began..."); break; caseUITouchPhaseMoved: NSLog(@"move..."); break; caseUITouchPhaseEnded: NSLog(@"end..."); break; default: break; } }}
然后在ViewController中响应该方法:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
关于多点触摸,可以参考Apple IOS SDK开发文档,多点触摸在游戏及其一些新奇的应用中比较多,在常规的应用开发中还是比较少的用到多点触摸。
下次将介绍UIControl对象