Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uiview 使用UITapgestureRecognitor和两个按钮查看_Uiview_Uibutton_Uitapgesturerecognizer - Fatal编程技术网

Uiview 使用UITapgestureRecognitor和两个按钮查看

Uiview 使用UITapgestureRecognitor和两个按钮查看,uiview,uibutton,uitapgesturerecognizer,Uiview,Uibutton,Uitapgesturerecognizer,我有一个UIView自定义类(m、h、xib),上面有两个按钮。如果我点击此视图,它应该会收到触摸,因此我实现了UITapGestureRecognitor: UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:customElementView action:@selector(customElementPressed:)]; [customElementView addGest

我有一个UIView自定义类(m、h、xib),上面有两个按钮。如果我点击此视图,它应该会收到触摸,因此我实现了UITapGestureRecognitor:

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:customElementView action:@selector(customElementPressed:)];
[customElementView addGestureRecognizer:tapGesture];
[tapGesture release];
该视图上甚至有两个按钮,每个按钮上都有一个在touchUpInside操作中实现的iAction


我的问题是这两个按钮没有接收到动作,每次我点击它们时,都会调用UIView的tap手势方法。我如何才能“强制”这些按钮抓住点击?

在发布新问题之前,请使用搜索功能。 搜索UIAPTgestureRecognitor和UIButton,将为您提供以下答案:

或者您可能想先尝试这种方法:


谢谢,第二个解决了我的问题。我不知道我以前怎么找不到它,但是我浏览了已经问过的问题。无论如何,谢谢!