那里。
我在 self.view 中添加了一个长按手势,但遗憾的是,这个手势每次被识别时都会触发不止一次。代码已列出。每次识别手势时,都会出现 2 个操作表。
- (void)viewDidLoad
{
[super viewDidLoad];
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:longPress];
}
-(void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Hello",nil];
[action showInView:self.view];
}