读书人

ios各种手势很好玩儿

发布时间: 2012-09-06 10:37:01 作者: rapoo

ios各种手势,很有意思

转自http://blog.csdn.net/likendsl/article/details/7554150 这哥们很厉害的

一、概述

iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式:

?- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
?- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
?- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
?- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

但是这种方式甄别不同的手势操作实在是麻烦,需要你自己计算做不同的手势分辨。后来。。。

苹果就给出了一个比较简便的方式,就是使用UIGestureRecognizer

二、UIGestureRecognizer

UIGestureRecognizer基类是一个抽象类,我们主要是使用它的子类(名字包含链接,可以点击跳到ios Developer library,看官方文档):

读书人网 >操作系统

热点推荐