ios触摸超出_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://www.cnblogs.com/marvindev
總結
以上是生活随笔為你收集整理的ios触摸超出_iOS开发笔记之多点触控(一)处理触摸的4个方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Qt正则表达式从字符串中取出手机号码
- 下一篇: 模式相似测度