iOS触摸事件

来源:互联网 发布:越南语离线翻译软件 编辑:程序博客网 时间:2024/06/06 13:53

在ios开发的触摸事件中包括:

 1.touchesBegan  触摸开始 在一次触摸事件中 只会执行一次

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

touches是NSSet集合,表示事件由几个手指操作,最多5个

 2.touchesMoved  触摸移动  在一次触摸事件中会执行多次

 3.touchesEnded  触摸结束  再一次触摸事件中会执行一次

    如果要调整控件 的位置可以使用 locationInView  previousLocationInView 计算移动的差值即可。

 4.touchesCancelled 触摸取消(通常在接电话时会触发)


[touches anyObject]从NSSet中取出touch对象

locationInView方法获得手指触摸的位置

原创粉丝点击