所以我有以下代码:
UITapGestureRecognizer *showNewsStoryTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showNewsStory:)];
[self.storyImageView_ addGestureRecognizer:showNewsStoryTapGestureRecognizer];
[self.storyTitleLabel_ addGestureRecognizer:showNewsStoryTapGestureRecognizer];
[self.storyImageFailedLabel_ addGestureRecognizer:showNewsStoryTapGestureRecognizer];
[self.storyImageFailedTextView_ addGestureRecognizer:showNewsStoryTapGestureRecognizer];
[showNewsStoryTapGestureRecognizer release];
这似乎只适用于一个UIView
,这是最后添加的一个UIView
,换句话说,是一个UITapGestureRecognizer
,它的 View 是一对一的关系。它是否正确?我该如何解决?我是否必须为每个创建一个单独的 UITapGestureRecog
?
最佳答案
是的,一个 UIView
只能有一个 UITapRecogniser
。尽管它们的 Action 可以相同,但您必须针对不同的 View 采用不同的识别器。
另请参阅this链接。
关于iphone - 向几个 UIView 添加一个手势识别器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11554763/