我有一个包含滚动图像 + 分页的 View 。我已将这些图像添加到 UIVIEW 上,并将此 UIView 添加到主视图。我想在 ScrollView 中检测图像上的点击事件并在主视图中处理它们。
我该怎么做?
请帮忙
最佳答案
你可以用手势识别器解决这个问题。
// In the view controller where you create the subviews
// (not sure from your question, but I think you are adding image views to a scroll view
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake...];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewTapped:)];
[imageView addGestureRecognizer:tap];
现在,这将在 ImageView 被点击时被调用
- (void)imageViewTapped:(UITapGestureRecognizer *)gr {
UIImageView *theImageViewThatGotTapped = (UIImageView *)gr.view;
}
关于iphone - 在主uiview的 subview 上获取点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9985927/