I have a problem with UIScrollView
, not sure if this is an error or not, but it occurs when I implement UIScrollView
with its delegate
and scalable / paged image.
First, when I pan the image, it is possible that the contentOffset
may not be an integer value (.5). Surely zoomScales
, when I swing the image to the edge, it drops half a pixel, shy to get to the edge because of this.
This is a very small thing, but in my application I need to drag objects around the screen, and if I drag an object to a corner, you may notice it.
I applied the following to try to fix the problem and make contentOffset
have to be an integer value:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { if (targetContentOffset->x != ceilf(targetContentOffset->x)) { if (velocity.x > 0) { targetContentOffset->x = ceilf(targetContentOffset->x); } else { targetContentOffset->x = floorf(targetContentOffset->x); } } if (targetContentOffset->y != ceilf(targetContentOffset->y)) { if (velocity.y > 0) { targetContentOffset->y = ceilf(targetContentOffset->y); } else { targetContentOffset->y = floorf(targetContentOffset->y); } } }
However, it does not work, since my targetContentOffset
completely different from the contentOffset
property.
Does anyone a) why this error occurs or b) how to fix it using the above delegation method or some other means?
source share