如何给button添加长按事件
展开全部
UILongPressGestureRecognizer *longPressGesutreRecognizer = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(handleLongPressed)];[longPressGesutreRecognizer setMinimumPressDuration:1];[frameButton addGestureRecognizer:longPressGesutreRecognizer];[longPressGesutreRecognizer release];-(void) handleLongPressed{// 在这里写处理长按事件的代码}UILongPressGestureRecognizer 是UIGestureRecognizer 的子类。手势识别类 UIGestureRecognizer 是一个抽象类,根据不同的手势,实现了具体不同的子类:UITapGestureRecognizerUIPinchGestureRecognizerUIRotationGestureRecognizerUISwipeGestureRecognizerUIPanGestureRecognizerUILongPressGestureRecognizer
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询