通过以下代码,我在手势识别器中附加了一个按钮:
UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(addLongpressGesture:)];
[longPress setDelegate:self];
[BUTTON addGestureRecognizer:longPress];
这是我的 addLongpressGesture 方法:
- (void)addLongpressGesture:(UILongPressGestureRecognizer *)sender {
UIView *view = sender.view;
CGPoint point = [sender locationInView:view.superview];
if (sender.state == UIGestureRecognizerStateBegan){
// GESTURE STATE BEGAN
}
}
通过这段代码sender.view
,我得到了附加的视图,UIView
但是我想要附加的视图(UIButton),我如何将 UIView 作为 UIButton?