iOS开发笔记之多点触控(一)处理触摸的4个方法

多点触控乃苹果公司带给世界的创新之首,作为移动开发者,熟练掌握多点触控开发技能很有必要。

处理触摸的四个方法:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event     //首次在屏幕上检测到触摸时调用
{
    NSLog(@"touchesBegan");
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event     //如果触摸移动到了新的位置则会调用此方法
{
    NSLog(@"touchesMoved");
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event    //当触摸离开屏幕调用此方法
{
    NSLog(@"touchesEnded");
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event    //如系统决定取消此次触摸,那可能就不调用touchesEnded方法了,在这种情况下会调用touchesCancelled方法
{
    NSLog(@"touchesCancelled");
}


快速点击屏幕,Debug窗口显示

2014-01-13 22:47:10.121 bbsTouch[593:70b] touchesBegan

2014-01-13 22:47:10.125 bbsTouch[593:70b] touchesEnded

2014-01-13 22:47:10.238 bbsTouch[593:70b] touchesBegan

2014-01-13 22:47:10.239 bbsTouch[593:70b] touchesEnded

2014-01-13 22:47:10.242 bbsTouch[593:70b] touchesBegan

2014-01-13 22:47:10.244 bbsTouch[593:70b] touchesEnded


点击并在屏幕上拖动,Debug窗口显示

2014-01-13 22:48:44.148 bbsTouch[593:70b] touchesBegan

2014-01-13 22:48:44.163 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.195 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.211 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.229 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.249 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.281 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.314 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.330 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.347 bbsTouch[593:70b] touchesMoved

2014-01-13 22:48:44.821 bbsTouch[593:70b] touchesEnded


touchesMoved可能不会在触摸队列中产生,然而,touchesBegan事件之后,总会产生touchesEnded或touchesCancelled事件。


转载请注明原著:http://blog.csdn.net/marvindev


下一篇介绍 iOS开发笔记之多点触控(二) 开启多点触控的方法



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值