iOS*_*Dev 4 iphone objective-c uiscrollview uiview ios
我有一个滚动图像+分页的视图.我在UIVIEW上添加了这些图像,并将此UIView添加到主视图中.我想在scrollview中检测图像上的click事件,并在主视图中处理它们.
我该怎么做?
请帮忙
dan*_*anh 17
您可以使用手势识别器解决问题.
// 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];
Run Code Online (Sandbox Code Playgroud)
现在,在点击图像视图时会调用此方法
- (void)imageViewTapped:(UITapGestureRecognizer *)gr {
UIImageView *theImageViewThatGotTapped = (UIImageView *)gr.view;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8890 次 |
| 最近记录: |