Basically, I want my app to behave like Photos.app does. When you zoom into an image, nothing special happens, it just makes that portion larger. However, if you then zoom out and the image has black letter boxing around it, it will center it properly so the black borders are balanced vertically and horizontally. So basically it will center it when needed, but leave it otherwise.
Many questions and their corresponding answers try to address this, but they seem to all implement it as the image is being zoomed. I just want it to center the image properly post zoom if needed. Is there an accepted way to do this?
Right now I simply have it like this:
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale {
[UIView animateWithDuration:0.3 animations:^{
[self centerViewInSuperview:self.imageBeingOverlayed];
}];
}
But it gets called "when it doesn't need to be called" (or when a user is zooming in on something specifically so the image needn't be centered). Should I just adjust that method to somehow detect when there's black bars around it and it doesn't need to be centered? Or is there a more widely accepted way?