如何检测用户在哪个图像对象上?
试图这样做,但它不工作
- (void)scrollViewDidScroll:(UIScrollView *)sender {
// [_imageScrollView contentOffset];
CGFloat imageViewWidth = _imageScrollView.frame.size.width;
//int currentPage = floor((_imageScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
NSInteger image = (NSInteger)floor((self.imageScrollView.contentOffset.x * 2.0f + imageViewWidth) / (imageViewWidth * 2.0f));
[_imageScrollView contentOffset];
//self.imageView.image = image;
}
编辑:如果我这样使用它仍然无法正常工作
- (void)LongPress:(UILongPressGestureRecognizer*)gestureRecognizer{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan){
CGPoint location = [gesture locationInView:_imageView];
CGFloat imageViewWidth = _imageScrollView.frame.size.width;
int imageView = floor((_imageScrollView.contentOffset.x - imageViewWidth / 2) / imageViewWidth) + 1;
NSLog(@"contains point?? - %d", CGRectContainsPoint(_imageView.bounds, location));
if (CGRectContainsPoint(_imageView.bounds, [self.view convertPoint:location toView:_imageView]))
{
UIImageWriteToSavedPhotosAlbum(_image, self, @selector(image: didFinishSavingWithError:contextInfo:), nil);
}
}}
如果我遗漏了什么,请告诉我。
谢谢