How can i detect which image object user is on?
Trying to do it this way but it is not working
- (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;
}
EDIT: If i use it like this still it is not working
- (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);
}
}}
Please let me know if i m missing something.
Thanks