您需要查看手势识别器,请查看以下文档:http UIGestureRecognizer
: //developer.apple.com/library/ios/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html
此示例可用于视图上的捏合手势:
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
// setup and add the view.
UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self
action:@selector(handlePinch:)];
[myView addGestureRecognizer:pinchGesture];
现在你必须实现一个被调用的方法handlePinch:
(这是你定义这个方法被调用的东西),你定义这个方法如下:
-(void)handlePinch:(UIPinchGestureRecognizer*)gesture {
// do what you want, all info about the pinch is in the gesture
}
您可以像这样“开箱即用”的其他手势是:
UITapGestureRecognizer
UIPinchGestureRecognizer
UIRotationGestureRecognizer
UISwipeGestureRecognizer
UIPanGestureRecognizer
UILongPressGestureRecognizer