//創建手勢
UILongPressGestureRecognizer
*longGesture = [[UILongPressGestureRecognizer
alloc]
initWithTarget:self
action:@selector(longPress:)];
//將創建好的手勢添加到你的控件上
[view
addGestureRecognizer:longGesture];
//添加事件
-(void)longPress:(UIGestureRecognizer
*)gr
{
//確保長按只執行一次
if (gr.state==UIGestureRecognizerStateBegan)
{
NSLog(@"long press ");
}